Link to home
Start Free TrialLog in
Avatar of IDEASDesign
IDEASDesign

asked on

Inserting text at the cursor position within a textarea using javascript

Good morning.  I need to figure out how to reliably Insert text at the EXACT cursor position within a textarea using javascript.  

In doing some quick research on the topic, I learned that this works inconsistently across different browsers, and my tests have confirmed this as well.

For example, .. it seems to work pretty well in Internet Explorer, .. but Firefox seems to have a problem with it.  And I haven't even tested it in Safari.  

Does anyone here know of a way that I could custom program this type of functionality (perhaps using javascript-based user agent detection which writes in different javascript based on which browser is detected) -- so that it works consistently across browsers? Ideally, I'd like to get it to work consistently in Internet Explorer, Firefox, and Safari.    

Or ... is inserting text at the EXACT cursor position within a textarea only possible In Internet Explorer?  Please advise.

Thanks,
- Yvan

Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

I have only seen IE do this consistently
Firefox might have a way too....

The search is the title of your question plus firefox

http://www.google.com/search?q=Inserting+text+at+the+cursor+position+firefox

and another word to use is Caret which is the cursor in the textarea
ASKER CERTIFIED SOLUTION
Avatar of hernst42
hernst42
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of IDEASDesign
IDEASDesign

ASKER

Thanks so much! The script works great!

- Yvan