PDA

View Full Version : Netscape Browser Settings Problem


boxxer03
11-18-2005, 08:01 AM
I had a quick question, the code below was just a screwing around kind of thing, but I thought it was decent so i added it to my site. It checks the users settings vs. the preferred setting for my website and lets the visitor know what matches the sites settings and what doesn't. It wokrs awesome in IE, but only the first line with the browser name comes up in Netscape. I was wondering why this happens and how/if I can fix it? You can see what it looks like at http://savepitbulls.8m.com/opti.html. It normally opens-up in a fitted pop-up but that's the direct link to the page. The code I used is below:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Save The Pit Bulls: System Check</title>
<style fprolloverstyle>A:hover {text-decoration: none}</style>
</head>

<body alink="#000000" link="#000000" text="#000000" vlink="#000000" bgcolor="#FFFFFF">
<script language="JavaScript">
<!--
document.write('<font face="verdana" style="font-size:10pt; color:000000">This is the Save The Pit Bulls System Check. If anything below appears in <font color="#00CC00"><b>green</b></font> then your computers settings match the settings recommended to best view this site. If anything appears in <font color="#FF0000"><b>red</b></font> then it does not match the requirements to best view this site.</font><br></br>')
document.write('<font face="verdana" style="font-size:10pt; color:000000">Browser name: <font color="#00CC00"><b>'+navigator.appName+'</b></font>.</font><br>')

if (navigator.browserLanguage.indexOf("en")!=-1){
document.write('<font face="verdana" style="font-size:10pt; color:000000">Browser language: <font color="#00CC00"><b>English</b></font>. [en : '+navigator.browserLanguage+']</font><br>')
}
else if (navigator.browserLanguage.indexOf("en")==-1){
document.write('<font face="verdana" style="font-size:10pt; color:000000">Browser language: <font color="#FF0000"><b>'+navigator.browserLanguage+'</b></font>. [en : english is preferred to view this site.]</font><br>')
}

if (navigator.javaEnabled()==true) {
document.write('<font face="verdana" style="font-size:10pt; color:000000">Javascript is: <font color="#00CC00"><b>Enabled</b></font>.</font><br>')
}
else if (navigator.javaEnabled()!=true) {
document.write('<font face="verdana" style="font-size:10pt; color:000000">Javascript is: <font color="#FF0000"><b>Disabled</b></font>. [JavaScript should be <u>enabled</u> to best view this site.]</font><br>')
}

if (screen.width==800||screen.height==600) {
document.write('<font face="verdana" style="font-size:10pt; color:000000">Screen resolution: <font color="#00CC00"><b>'+screen.width+' x '+screen.height+'</b></font>.</font><br>')
}
else if (screen.width!=800||screen.height!=600) {
document.write('<font face="verdana" style="font-size:10pt; color:000000">Screen resolution: <font color="#FF0000"><b>'+screen.width+' x '+screen.height+'</b></font>. [800 x 600 is recommended to best view this site.]</font><br>')
}

if (screen.ColorDepth==32) {
document.write('<font face="verdana" style="font-size:10pt; color:000000">Screen color: <font color="#00CC00"><b>'+screen.colorDepth+' bit</b></font>.</font><br>')
}
else if (screen.ColorDepth!=32) {
document.write('<font face="verdana" style="font-size:10pt; color:000000">Screen color: <font color="#FF0000"><b>'+screen.colorDepth+' bit</b></font>. [32 bit color is recommended to view this site.]</font><br>')
}

if (screen.bufferDepth==0){
document.write('<font face="verdana" style="font-size:10pt; color:000000">Screen buffer depth: <font color="#00CC00"><b>0</b></font>.</font><br>')
}
else if (screen.bufferDepth!=0){
document.write('<font face="verdana" style="font-size:10pt; color:000000">Screen buffer depth: <font color="#FF0000"><b>'+screen.bufferDepth+'</b></font>. [0 is suggested to view this site.]</font><br>')
}
//-->
</script>
</body>

</html>

PhotoJoe47
11-18-2005, 08:27 AM
Netscape 8.0.4 gives an error in it's javascript console:

Error: navigator.browserLanguage has no properties
Source File: http://savepitbulls.8m.com/opti.html
Line: 15

Foxfire 1.0.6 & Nestscape 7.2 give the same error in the javascript console.

So I would say that navigator.borwserLanguage is a IE only property

glenngv
11-18-2005, 09:29 AM
Moz simply uses navigator.language. To see all the supported properties/methods of navigator object, run this code:
var s='';
for (var i in navigator)
s += i + "=" + navigator[i] + "\n";
alert(s)

So your code would be:

var lang = (navigator.browserLanguage) ? navigator.browserLanguage.toLowerCase() : (navigator.language) ? navigator.language.toLowerCase() : ""; //or you may set default to "en"

if (lang.indexOf("en")!=-1){
//english
}

boxxer03
11-19-2005, 07:08 AM
awesome, thanx, it works great now. just a couple more questions if anyone can answer them. once again, it works fine in IE, but for the screen.colorDepth and navigator.javaEnabled() attributes are messed up. you can see the code for them above, or check it out at the link above too, but basically it's returning the screen.colorDepth fine and it's supposed to display it green because it's the right colorDepth but it's showing up red like it's incorrect, but it's showing the right bits [32] and navigator.javaEnabled() is returning false even though it's enabled in my netscape. Its easier to understand if you check out the code above and then visit the site I listed above. can someone help me please? thanx for the previous help too!