jarrett000 Posted April 3, 2009 Share Posted April 3, 2009 This is kind of a noob script cause I just finished the JS lessons and am still studying the more advanced and all areas of DOM, but what I want to do is that if the browser isn't netscape (which for some reason is forefox) at the newst version, a redirection should occur. This is my script so far: function SendUser(){var A=navigator.appName;var B=navigator.appVersion;if ((!A=="Netscape") && (!B>2)) { top.location="http://www.mozilla.com/en-US/firefox/firefox.html"; }} But it dosen't work and I don't know why. Link to comment Share on other sites More sharing options...
jeffman Posted April 3, 2009 Share Posted April 3, 2009 Have you tried alert(navigator.appVersion) ? The result may not be what you expect . . . Link to comment Share on other sites More sharing options...
jarrett000 Posted April 3, 2009 Author Share Posted April 3, 2009 Thanks for the information on the version, but internet explorer does still display the page without redirection, any idea why? Link to comment Share on other sites More sharing options...
jesh Posted April 3, 2009 Share Posted April 3, 2009 You might be better off using IE's conditional comments for something like this. <html><body><!--[if IE]><script type="text/javascript">location.href = "http://www.w3schools.com/";</script><![endif]-->Hi non-IE user!</body></html> Link to comment Share on other sites More sharing options...
jarrett000 Posted April 3, 2009 Author Share Posted April 3, 2009 Thx for the tip. I honestly didnt know that I could actually use comments in any way I thought they were useless. I'll have to study into that. Link to comment Share on other sites More sharing options...
justsomeguy Posted April 6, 2009 Share Posted April 6, 2009 Also, these aren't going to do what you want:if ((!A=="Netscape") && (!B>2))That the same as this:if (( (!A) == "Netscape" ) && ( (! > 2))The expression (!A) is probably going to evaluate to false, so that line is the same as this:if (( false == "Netscape" ) && ( false > 2)) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.