Page 1 of 1

JavaScript: add text to textbox

Posted: Wed Mar 02, 2005 12:18 pm
by Shendemiar
I'm using similiar javascript function that "add emoticons" aka emoticons on this page, to add some special strings to textarea.

It allways adds the strings to the end of the existing text. I'd like to know if it's possible for javascript to detect the position of the cursor in the textarea and add strings into that position, into middle of the existing text?

Alternatively, id like to add the chosen string to clippoard, so it can be pasted where wanted. Is it possible to add stuff to clipboard by javascript?

Posted: Wed Mar 02, 2005 12:28 pm
by feyd
http://www.alexking.org/blog/2003/06/02 ... avascript/

clipboard: only possible in IE that I know of.. through execommand() or something..

Posted: Wed Mar 02, 2005 2:22 pm
by Shendemiar
Great trick, works on every browser execpt opera, thanks!