Click to See Complete Forum and Search --> : JS and Netscape question


troy1984
11-03-2003, 03:45 PM
Hi all,
Im have a javascript that works in both IE as in Netscape.
But if i put it in an external (.js) file then it works only in Internet Explorer. I know netscape has problems with some external css files does this goes for js to? Or is it more obvious there's something wrong with my way of transfering the code to an js file.

Thanks readers,
Troy

fredmv
11-03-2003, 04:21 PM
I think this may be a problem related to caching. Try adding these to your <head> and see if it makes any difference:<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />That should prevent the page from being cached.

Good luck.

gil davis
11-03-2003, 09:42 PM
Start with the javascript console (in NS 4, type "javascript:" in the location bar - in NS 6+, click on Tools|Web Development|Javascript Console) and look for errors. There will probably be some.

The most common mistake people make when they transfer a working script to a .js file is they leave the HTML <script> tag in it (illegal) or leave the comment string, e.g.:

<script language="javascript">
<!-- // to hide from old browsers
...
//-->
</script>

None of this should be in the .js file, only the bit represented by the "...".

troy1984
11-04-2003, 12:03 PM
I dit that. :S

I've got this in my html file :

<script language="JavaScript" type="text/javascript" src="java/3box.js"></script>

And the code in the .js file.

It doesn't make sence to me

gil davis
11-04-2003, 12:19 PM
Post a link, or zip all the files up and attach them to your reply.

troy1984
11-04-2003, 01:15 PM
It doesn't work in explorer to :S

I made a zip containing:

The file as i want it (script in a js)

And the exact same script intern that DOES work.

www.trespassersw.nl/rask/externaljs.rar

Thanks for helping me,

Greetings,
Troy

troy1984
11-04-2003, 04:27 PM
Figured it out tnx guys!!