Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-10-2002, 03:16 PM   PM User | #1
surfsup
New to the CF scene

 
Join Date: Jul 2002
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
surfsup is an unknown quantity at this point
Question Use different .js files based on browser type?

How can I use different .js files based on the browser type? The below code does not work, please help.

Thanks William.

<script language="JavaScript1.2">
if (document.layers) { // NetScape 4.x
src="netscape4x_menu.js"
}
else { // IE or NetScape 6/Mozilla
src="non_netscape4x_menu.js"
}
</script>
surfsup is offline   Reply With Quote
Old 07-10-2002, 03:31 PM   PM User | #2
tamienne
Regular Coder

 
Join Date: Jun 2002
Location: Delaware, USA
Posts: 138
Thanks: 0
Thanked 0 Times in 0 Posts
tamienne is an unknown quantity at this point
<script language="JavaScript1.2">
if (document.layers) { // NetScape 4.x

document.write("<SCRIPT LANGUAGE='JavaScript1.2' SRC='netscape4x_menu.js' TYPE='text/javascript'><\/SCRIPT>");

} else { // IE or NetScape 6/Mozilla
document.write("<SCRIPT LANGUAGE='JavaScript1.2' SRC='non_netscape4x_menu.js' TYPE='text/javascript'><\/SCRIPT>");

}
</script>
tamienne is offline   Reply With Quote
Old 07-10-2002, 03:33 PM   PM User | #3
requestcode
Regular Coder

 
Join Date: Jun 2002
Posts: 626
Thanks: 0
Thanked 0 Times in 0 Posts
requestcode is an unknown quantity at this point
I don't beleive you can do that. Why don't you combine both scripts into one exteranal file?

I stand corrected. I tested it and you can, but I still wonder why you don't combine the two scripts.

Last edited by requestcode; 07-10-2002 at 03:41 PM..
requestcode is offline   Reply With Quote
Old 07-11-2002, 02:22 PM   PM User | #4
surfsup
New to the CF scene

 
Join Date: Jul 2002
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
surfsup is an unknown quantity at this point
I copied and pasted the code from Tamienne into
the <head> of a page and I receive javascript
error messages.

Thanks William.
surfsup is offline   Reply With Quote
Old 07-11-2002, 03:18 PM   PM User | #5
JohnKrutsch
Regular Coder

 
Join Date: Jun 2002
Location: The Planet Earth Code Poet: True
Posts: 282
Thanks: 0
Thanked 1 Time in 1 Post
JohnKrutsch is an unknown quantity at this point
Make sure you don't have line breaks in there:

Code:
<script language="JavaScript1.2"> 
if (document.layers) { // NetScape 4.x 

document.write("<SCRIPT LANGUAGE='JavaScript1.2' SRC='netscape4x_menu.js' TYPE='text/javascript'><\/SCRIPT>"); 

} else { // IE or NetScape 6/Mozilla 
document.write("<SCRIPT LANGUAGE='JavaScript1.2' SRC='non_netscape4x_menu.js' TYPE='text/javascript'><\/SCRIPT>"); 

} 
</script>
JohnKrutsch is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:08 AM.


Advertisement
Log in to turn off these ads.