Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javascript, help please IE vs. Netscape

Status
Not open for further replies.

brynjan

Programmer
May 7, 2001
5
0
0
SE
Does anyone have the solution on this problem?
it is soposed to be <b> tags around a marked selection in a textfield but it won't work in Netscape 4.7
but in explorer.

<FORM NAME=&quot;myForm&quot;>
<TEXTAREA NAME=&quot;myArea&quot; COLS=&quot;40&quot; ROWS=&quot;4&quot;></TEXTAREA>
<input type=button value=&quot;fet stil&quot; onclick=&quot;fet()&quot;>
</FORM>

<script language=&quot;JavaScript&quot;>
function fet()
{
if (document.getSelection)
{
sel=document.getSelection //netskräp
}

else if (document.selection)
{
sel=document.selection //exploder
}
else
{
// annan browser
}

range=sel.createRange()
thetext=range.text
if (thetext.length)
{
range.text=&quot;<b>&quot;+thetext+&quot;</b>&quot;
}

}
</script>
 
looks like netscrap doesn't support textRange object (for me, at least..) so, sel.createRange() won't work.. Victor
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top