View Full Version : External JS file working fine in IE, NS4 but not in NS6

08-04-2002, 07:04 PM

I got this code from JavaScriptKit.com. The orignal script has the code embedded in the html file. I managed to get it working as an external .js file in IE6 and NS4 but in NS6 its a no-go.

The orignal code works fine in NS6 so the code by its self is compatible with it.

Ne ideas? Thanks in Advance :) !


08-04-2002, 11:58 PM
All I know is that I've experienced this problem before with another JS. And as you can guess, my "fix" was to not use the external JS file. Being that the JS was to be included in all of my pages on the site, it's just a pain. But, no other solution was ever found.

08-05-2002, 05:19 AM
NS6 is very picky about quotation usage sometimes... the only reason NS6 isn't working with your external .js file is because in the <script> line, you don't have quotation marks around the filename... so while you have
<SCRIPT LANGUAGE='JavaScript' src=triplecombo.js></script>
you should have
<SCRIPT LANGUAGE='JavaScript' src='triplecombo.js'></script>

Tested it on mine and it works.

08-05-2002, 05:48 AM

Inserting and maintaining the code in every page will be a real bummer :(

And inserting the quotes around triplecombo.js didnt work on ns6 here :confused: Am using 6.2, could that be a reason?

One more thing though, just read abt the javascript console help in netscape ... it gives the following Error: document.isc has no properties ...

do you think with NS6 and its "new engine" objects like forms in external files would have to be created using DOM/JavaScripting?

Currently the script uses a document.write("<form></form>") to create a form ... Could this be the problem?

Anyways, thanks for your help :)


08-05-2002, 05:51 AM
thevice, I'm not sure if you missed my post or what, but the only problem in your code is that you don't have quotation marks around the file name... if you just add quotation marks, you won't have to insert the code into every page, because the external .js file will work...

08-05-2002, 06:05 AM
I had missed your post ... and while i was editing the reply, missed your next one :o

A nice bit o' comedy of errors :)

Really appreciate your help!


08-05-2002, 06:20 AM
Heh, well, I found the real problem this time... the reason I thought the quotes were the problem was because I was playing with two things at once, so when it started working, I thought it was the quotations, when really it was the other thing...
So anyway, the reason it doesn't work is because NS 6 does some really weird things when you try writing a <script> tag when you're already inside another <script> tag... in the example from your download, you had something like this:

if (document.all || document.layers)
document.write("<SCRIPT LANGUAGE='JavaScript' src=triplecombo.js></script>")
document.write("<SCRIPT LANGUAGE='JavaScript' src=triplecombo.js></script> ")

Most of that code is completely redundant... if you write this instead, it should work:

<SCRIPT LANGUAGE='Javascript' src='triplecombo.js'></SCRIPT>

That works for me in NS 6.2

08-05-2002, 07:11 AM
Great! It works!:thumbsup:

BUT (isnt there always a but?) ...

the reason for those lines of code were to enable the browser to pick up code from an external file say a.js if it were ie/netscape4 and b.js if it was netscape6up.

Is there a way to include an external file without the <script src> tags?


08-05-2002, 07:39 AM
Well, while trying to answer this, I thought up trying to change the src of the current <script> tag dynamically... while this works in IE, Netscape doesn't seem to like people messing with script src's dynamically and throws some weird errors...

Anyway, all that I've managed to thinkup that would work is either try using iframes to include the script file (I'm not sure it would work, and you would have to change the js file a bit... I don't really use them, so I don't know...), or you could try combining your two .js files (the one for NS6 and the one for the others) into a single .js file - all you would have to do is make a new .js file, write if (document.all||document.layers){, then copy and paste your script for IE/NN, then put an 'else' after that and put your NS6 script...

08-05-2002, 08:58 AM
try slicing the word script in the document.write. Sometimes browsers mess up when finding script tags in document.write's.

if (document.all || document.layers)
document.write("<S"+"CRIPT LANGUAGE='JavaScript' src=triplecombo.js><\/script>")
document.write("<S"+"CRIPT LANGUAGE='JavaScript' src=triplecombo_ns6.js><\/script> ")

08-06-2002, 11:34 AM
Sorry i took a long time to reply ...

Neways ... the slicing etc didn't help ... but noticed that ther error document.isc has no properties could only mean that somehow ns6 was not recognising the form being created by the external script ... took a wild shot and moved the document.write(<form ..> ... </form>); part to the main page and it worked! finally moved the that form to another external js file and added another loop to execute the combobox script(dint wrk in the same loop) and its wrkg real fine :)

I guess NS6 is real picky about hierachy and in fact seemingly everything else ... which may be a good thing after all!

Thanks to everyone for your help! would have given up on this one if it wasnt for you'll!


p.s. attaching the complete set of files in case anyone is interested!