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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

linking in jscript. not working in NS

Status
Not open for further replies.

avivit

Technical User
Jul 5, 2000
456
IL
I've tried to build very very very simple code in order to know where is the problem in the full code I wrote.
I still do not understand why this code functions in IE only, and how will it work when I'm using NS.
The interesting fact is that if I replace the "document.write(name)" with alert(name)
it works perfectly with both browsers.
Please give me only practical answers, I've been dealing with that for quite long time.
Thanks a lot
The code:
<html>
<body>
<script language=&quot;Javascript&quot;>
<!--
document.write(&quot;<a href='javascript:newWind(&quot;+'&quot;abc&quot;'+&quot;);'>Aleph home</a><br>&quot;);

function newWind(name)
{ document.write(name);
}
//-->
</script>
</body>
</html>
 
The reason is that the first time you use document.write, Netscape writes a &quot;whole new document&quot; that only has the contents: <A href='javascript:newWind(&quot;abc&quot;);'>Aleph home</A><BR>

When you load this page in Netscape 4.73 or 4.75, take a peek at the source code.

Netscape 4.x uses document.write a little differently than IE. Basically, document.write means &quot;redo the page from scratch&quot;, which Netscape does, losing all other content, but IE apparently preserves the function values, understanding that they might still need to be used. Also, you might have trouble using &quot;name&quot; as a variable name.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top