JavaScript syntax help
Hi,
I need help with JavaScript syntax (definitely not my strong point). I'd like to combine the following two statements:
<script language="javascript">
<!--
document.write("<img src=\"images/spacer1x1.gif\" width=\"1\" height=\"60\" alt=\"Navigation Bar\">")
// -->
</script>
and
if ((navigator.appName == "Netscape") && (document.getElementById) )
{
.. refer to external .js file if NS6
}
so that what it says is this:
Write out the spacer image unless the browser is Netscape 6. If the browser is Netscape 6, then read an external .js file (I don't know how to call the .js file either).
Can anyone help me with this syntax? I would really appreciate it!
Thanks, Phyllis
[email protected] posted this at 19:10 — 6th February 2001.
They have: 12 posts
Joined: Oct 2000
did you try this?.. not positive if this is what you want or not..
<script language="javascript">
<!---//
if ((navigator.appName == "Netscape") && (document.getElementById) )
{
document.write("<script src='whatever.js' language='javascript'><\/script>")
}
else
{
document.write("<img src='images/spacer1x1.gif' width='1' height='60' alt='Navigation Bar'>")
}
// -->
</script>
[Edited by [email protected] on Feb. 06, 2001 at 03:30 PM]
Give me what I want, and I'll go away!
phyllis posted this at 19:54 — 6th February 2001.
They have: 59 posts
Joined: Mar 2000
Hey thanks! I think that's going to work (I'm about to experiment with it). I have a tough time with the syntax -- I understand it after I see it, but trying to write it myself I often get lost in it. Oh well!
Thanks again,
Phyllis
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.