JavaScript syntax help

They have: 59 posts

Joined: Mar 2000

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\">")

// -->
&lt;/script&gt;
'

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

They have: 12 posts

Joined: Oct 2000

did you try this?.. not positive if this is what you want or not..

&lt;script language="javascript"&gt;
<!---//

if ((navigator.appName == "Netscape") && (document.getElementById) )
{
document.write("&lt;script src='whatever.js' language='javascript'&gt;<\/script>")
}
else
{
document.write("<img src='images/spacer1x1.gif' width='1' height='60' alt='Navigation Bar'>")
}
// -->
&lt;/script&gt;
'

[Edited by [email protected] on Feb. 06, 2001 at 03:30 PM]

Give me what I want, and I'll go away!

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.