Forum Moderators: open

Message Too Old, No Replies

Script works in IE not in Netscape

         

Acternaweb

12:41 pm on Jun 21, 2001 (gmt 0)

10+ Year Member



I have set up a javascript to test screen resolution and a browser sniffer. Currently I have 2 separate scripts that work as they are supposed to in IE. However when I go to Netscape, only one works. I can not find my mistake.

Should I post the code here for your help?

Thanks,

Paul

knighty

1:06 pm on Jun 21, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



yes post the code

Acternaweb

2:34 pm on Jun 21, 2001 (gmt 0)

10+ Year Member



here you go:

Thanks for your help
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var bestwidth = 800;
var bestheight = 600;
if (screen.width != bestwidth ¦¦ screen.height != bestheight) {
msg = "This site looks best when viewed when your screen "
+ "is set to a " + bestwidth + "x" + bestheight + " resolution, "
+ "but your screen resolution is " + screen.width + "x"
+ screen.height + ". Please change your screen resolution "
+ "to best view the site, if possible. Thanks!";
document.write(msg);
}
else
if (screen.width == bestwidth ¦¦ screen.height == bestheight) {
msg = "<font face='Comic Sans MS, Arial'><center>Congrats, your screen resolution is set at the best resolution.";
document.write(msg);
}

// End -->
</script>

<script language="JavaScript">
<!-- Script Begin
if (navigator.appName == "Microsoft Internet Explorer") {
msg = "<font face='Comic Sans MS, Arial'>You are using a version of IE which will give you the full effect of our site.<BR>"
+ "Please visit us often";
document.write(msg);
}
else
if (screen.width == "Netscape") {
msg = "You are currently viewing the site using Netscape. "
+ " While our site is visable through Netscape, we recommend using IE 5.0 or"
+ "newer"
+ "You can <a href='http://www.microsoft.com/windows/ie/default.htm'>get IE 5.5 here </a>";
document.write(msg);
}

</script>

Steph

3:14 pm on Jun 21, 2001 (gmt 0)

10+ Year Member



> if (screen.width == "Netscape")

remplace this by
(navigator.appName == "Netscape") and i think it would be work better :)

knighty

3:30 pm on Jun 21, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




remove the line <!-- Script Begin from the second script or end it

not so sure about nesting the url inside the script either but might be ok

Acternaweb

5:35 pm on Jun 21, 2001 (gmt 0)

10+ Year Member



That seemed to do it.. never realized Begin and end were important to netscape.

Thanks,