[thelist] js cursor position in a form

Peter Brunone (EasyListBox.com) peter at easylistbox.com
Wed Jan 4 23:42:06 CST 2006

The createTextRange part is IE-specific.  The Mozilla approach looks like this:

inputText.setSelectionRange(iStartPosition, iEndPosition)

This might work in IE also; I haven't tested it there.

 From: Brian Cummiskey Brian at hondaswap.com

Peter Brunone (EasyListBox.com) wrote:
> Hi Brian,
> Here's an IE-only approach (there's a Mozilla way as well, which I can provide if you need it):
> var inputText = myTextInput.createTextRange();
> // move to the fourth character
> inputText.moveStart("character", 4);
> // this will select any text after it so a keypress will 
> // delete the old text and start adding new text
> inputText.select(); 

Thanks Peter- I'll give this a try tomorrow morning when I'm at the office.

Just out of curiosity, do you know which function(s) are ie-specifc, 
thus causing it not to work cross-browser?

More information about the thelist mailing list