James wrote regarding '[EE] IE textRange guru needed' on Tue, Feb 14 at 12:50: > I hope that makes sense. Now, I have all that working in IE /except/ for the > part about the position of the cursor. One is supposed to be able to move > the thing with the .move("character",distance) method to a textRange object > where distance is the negative or positive number of characters to move. And > I have seen it work before, but for some.... amazingly frustrating... > reason, it will not work here. > if (document.selection) { > anArea.focus(); > var aSel = ( anArea.caretPos ? anArea.caretPos : > document.selection.createRange() ); > if (aSel.text.charAt(aSel.text.length-1)==' ') > aSel.moveEnd('character',-1); > aSel.text = startTxt + aSel.text + endTxt; > anArea.createTextRange().move("character",-4); > } What the documentation doesn't note is that, if you create a new range, the range is created at the beginning of the text area. So when you create a new textRange in your textarea, the range is at at 0-0, so a negative number will move to to 0 (negative values don't work) and a positive number will move from the start point of the textbox - not the selection. In order to get the cursor positioned, you want to move relative to the selection (it'll be relative to the end of the seelction, regardless of the direction the text was selected in), and then reselect the text range. I'm not sure why that works, but it does (if this wasn't IE and it's pile of quirks, I'd research it until I knew - but it's probably "just the way it is" rather than for any good reason). Use these two lines instead of your last line where you create a new area, and it should work better. aSel.move('character',-4) aSel.select(); --Danny -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist