Greetings,
As you said in a later mail that the variable (NS) was being set with;
var NS = (document.layers);
well if the page is being viewed in NS 4 this is fine and will return true,
however in NS 6 & 7 (as has been said by Robert) will not work and will
remain undefined.
Therefore your code;
var skn = (ns) ? document.layers.infopop : top.main.document.infopop.style;
will return false, i.e. top.main.document.infopop.style
is this what you want?
The best thing to do here is to check for the type AND version of the
browser and build your code to suit either or, or both. It's a lot more work
(typing) but it depends on the user base you wish to cover... not everyone
uses the latest version of any browser.
As a string point i would suggest using the following;
// convert all characters to lowercase to simplify testing
var agt = navigator.userAgent.toLowerCase();
var appVer = navigator.appVersion;
// check for Netscape Navigator
var NS = (navigator.appName == 'Netscape') ? 1 : 0;
var NSL = (document.layers) ? 1 : 0;
// check for MS Internet Explorer
var IE4 = (agt.indexOf('msie 4') != -1) ? 1 : 0;
var IE5 = (agt.indexOf('msie 5') != -1) ? 1 : 0;
var IE6 = (agt.indexOf('msie 6') != -1) ? 1 : 0;
var MSIE = (IE4 || IE5 || IE6) ? 1 : 0;
var IEA = (document.all) ? 1 : 0;
// check for Version 4 or > browsers
var ver4 = (parseFloat(appVer) >= 4) ? 1 : 0;
document.write('Agent: ' + agt);
document.write('<br>');
document.write('NS: ' + NS + ' MSIE: ' + MSIE);
document.write('<br>');
document.write('NS Layers: ' + NSL + ' IE All: ' + IEA);
document.write('<br>');
document.write('IE4: ' + IE4 + ' IE5: ' + IE5 + ' IE6: ' + IE6);
document.write('<br>');
document.write('Ver 4: ' + ver4);
document.write('<br>');
document.write('Nav: ' + navigator.appName);
document.write('<br>');
document.write('Ver: ' + appVer);
document.write('<br>');
Using the above you can then determine if the browser is being ID'd as
Netscape or not and if the browser supports layers, you could also modify
the code to get the exact version of the browser if you so wished...
HTH
-----Original Message-----
From: Tim Morford [mailto:tmorford@n...]
Sent: 26 September 2002 13:15
To: P2P JavaScript
Subject: [javascript] Error on page with frames
Hello, I am getting an error on this line, It is in a .JS file, I have
tried running it with in the page it still give the same error.
Line: body.js
var skn = (ns) ? document.layers.infopop :
top.main.document.infopop.style;
Call line: 02.html
<DIV id="infopop" name="infopop"
style="position:absolute;left:68px;top:455px;width:440px;height:45px;z-index
:9"></DIV>
The file is being called in the 02.htm and is working, other parts of the
.JS file works? any suggestions?
--
Tim Morford
---
Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20