Click to See Complete Forum and Search --> : calling a javascript inside a javascript


webguzs1
06-16-2004, 08:14 AM
my question is:

what is the command line to send the browser looking for a
specific java script line. (A java script inside a Java script).

Im thinking of using the script below but the location.href
is not good. does anyone khow the proper syntax?

<SCRIPT LANGUAGE="JavaScript"><!--
if (navigator.appName == 'Netscape')
<<<<<<<<<location.href = 'netscape.html';>>>>>>>
else {
if (navigator.appName == 'Microsoft Internet Explorer')
<<<<<<<<<location.href = 'explorer.html';>>>>>>>
else if (navigator.appName == 'netscape')
<<<<<<<<<location.href = 'othernetscapepage.html';>>>>>>>
}
//--></SCRIPT>

sciguyryan
06-16-2004, 11:40 AM
I;m not shure this is possible using Javascript.

AdamGundry
06-16-2004, 01:14 PM
I'm not certain what you mean - can you explain in more detail what you are trying to do, please.

Adam

Pittimann
06-16-2004, 01:25 PM
Hi Adam!

webguzs1 wants an external js file to be called depending on the user's browser. He/ she made it a bit clearer in another thread.

Regards - Pit

AdamGundry
06-16-2004, 02:13 PM
In that case you can possibly do something like this (I haven't tested it, but I think it should work):

<script type="text/javascript">
if (navigator.appName == 'Netscape'){
document.write('<script type="text/javascript" src="netscape.js"></script>');
} else if (navigator.appName == 'Microsoft Internet Explorer'){
document.write('<script type="text/javascript" src="explorer.js"></script>');
} else if (navigator.appName == 'netscape'){
document.write('<script type="text/javascript" src="other-netscape.js"></script>');
}
</script>

Adam

Pittimann
06-16-2004, 02:28 PM
Sorry Adam! :(

I should have mentioned, that I already posted something like this to the other thread.

Cheers - Pit