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

use javascript to load external .js file in Netscape 7

Status
Not open for further replies.

crw150

Technical User
May 27, 2005
20
Hi,
I'm a javascript novice and have searched for days but am still lost. The code below is supposed to load an external .js file depending on the browser in use. It works fine for IE and Firefox. But it Netscape 7 it only loads the css file, not the .js file. I've tried all the variations I could find (like using "language" attribute instead of "type" attribute, breaking the word "script" with a + sign, etc.) but still no luck. What is the correct command and syntax to use to get Netscape 7 to load an external .js file? Please tell me what's wrong, or point me to a web site or tutorial, or tell me what key words to use for searching. Any help will be greatly appreciated!
CRW
(The reDo function is for another purpose, but I'm showing complete script as is in case that's an issue.)

Code:
<script type="text/javascript">				
  <![CDATA[
  if (document.getElementById) 	{
    document.write('<script type="text/javascript" src="file:///C:/Menus/jsdropdown/indexFiles/ie.js"><\/script>');
}
else {
    document.write("<link rel='stylesheet' href='file:///C:/WbDesign/Stylesheets/nn.css' type='text/css'>"); 
    document.write('<script type="text/javascript" src="file:///C:/Menus/jsdropdown/indexFiles/nn.js"><\/script>');
}
function reDo(){ location.reload() }
  window.onresize = reDo;
  ]]>
</script>
 
I find it odd that NN7 is getting into the ele portion altogether, given that it supports getElementById. Can you confirm that it is getting into the else statement, rather than running the first document.write?

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Hi Dan,
No, I can't confirm that it's getting into the else statement. Because, duh, it isn't. I guess because it worked in IE and FF I got sidetracked, but after your post I kept fiddling with the code. It now works in IE, FF and NN. I don't even know why, but it's fixed. So sorry to clutter the list with a dumb question, but you made me see I needed to look elsewhere. Thanks so much!
Banging head on desk,
CRW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top