Well after the long Christmas break I'm finally back on-line, although my first post is to ask for help.
I am working on a simple admin panel for a site I have - it will enable other people to keep the main areas of the site up to date if I am not available. Part of this admin process needs an insert at cursor function so people can insert images at the right place.
The code I have (see below) works fine for FF but for IE nothing happens.
Expand|Select|Wrap|Line Numbers
- function insertAtCursor(myField, myValue)
- {
- var loTextArea = document.getElementById(myField) ;
- if (document.selection)
- {
- //IE support
- myField.focus();
- sel = document.selection.createRange();
- myValue = myValue + sel.text;
- }
- else if (loTextArea.selectionStart || loTextArea.selectionStart == '0')
- {
- //MOZILLA/NETSCAPE support
- var startPos = loTextArea.selectionStart;
- var endPos = loTextArea.selectionEnd;
- loTextArea.value = loTextArea.value.substring(0, startPos) + myValue + loTextArea.value.substring(endPos, loTextArea.value.length);
- }
- else
- {
- loTextArea.value += loTextArea;
- }
- }
So in FF the insert happens where the cursor is but in IE nothing happens at all.
Any ideas on what is going wrong here?
Many thanks
nathj