I'd like to have a similar thing to the smileys, where an onclick adds content to the FCK editor at the cursor position. I'm not adding smileys but links to resources on our site, listed in divs with onclicks.
I can do this with an onclick on an element like this very basic example. This isn't the problem.
which calls the function
Problem is the link is always put at the start of the textarea but I'd like it to go at the cursor position.
Below is the code for an IE workaround. All it does is make a click anywhere else on the page fail. It of course make the text unselectable too which isn't ideal.
So I'd like a cross browser (ie and FF at least) way to add content to a textarea in FCK at the cursor position.
Any ideas?
Code Snippet:
I can do this with an onclick on an element like this very basic example. This isn't the problem.
<div onclick="enterHTML('FCKeditor1')">test</div>which calls the function
<script type="text/javascript">
<!--
function enterHTML(editorInstance){
var oEditor = FCKeditorAPI.GetInstance(editorInstance) ;
oEditor.InsertHtml('Heres your link ');
oEditor.InsertHtml('<a href="#">link me up</a> <br>');
}
//-->
</script>Problem is the link is always put at the start of the textarea but I'd like it to go at the cursor position.
Below is the code for an IE workaround. All it does is make a click anywhere else on the page fail. It of course make the text unselectable too which isn't ideal.
So I'd like a cross browser (ie and FF at least) way to add content to a textarea in FCK at the cursor position.
Any ideas?
Code Snippet:
<script type="text/javascript">
<!--
if (navigator.appName=="Microsoft Internet Explorer") {
var all = document.all;
var l = all.length;
for (var i = 0; i < l; i++) {
if (all[i].tagName != "INPUT" && all[i].tagName != "TEXTAREA" && all[i].tagName != "IFRAME") {
all[i].unselectable = "on"; }
}
}
//-->
</script>
Re: How can I add content onclick to a textarea at cursor positi