JavaScript: add text to textbox

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

JavaScript: add text to textbox

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

http://www.alexking.org/blog/2003/06/02 ... avascript/

clipboard: only possible in IE that I know of.. through execommand() or something..
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

Great trick, works on every browser execpt opera, thanks!
Post Reply