PDA

View Full Version : Netscape equivalent of CreateTextRange?


pthompson2002
09-09-2002, 04:12 PM
I have used the following code in IE5 to highlight a specific piece of text in a text box, but I have discovered that this does not work in Netscape 4+, can anyone tell me the equivalent of such a function that works for NN?

cheers

Pete

-----------------------------------------------

var rng = thisform.characters.createTextRange();
if (rng.findText(ch)) { //ch is a predifined rng.select();
}

----------------------------------------------------

Bosko
09-09-2002, 08:47 PM
In Mozilla (Netscape 6+) you can use the setSelectionRange() method of a textbox.Just call .setSelectionRange(Start,End),where Start is the place where the selection begins and End the place where the selection ends.Heres an example:

<input type="text" value="Mozilla!" id="textbox">
<input type="button" value="Select the text 'Moz' in the textbox." onclick="javascript:document.getElementById('textbox').setSelectionRange(0,3)">


Btw,its logical that it doesnt work in Mozilla/Netscape since IE uses its sucky propriatary methods and Mozilla the W3 standards.And NS4 is 5 years old,its like trying to do this in IE3 (which is impossible).