LMarie Posted September 28, 2009 Share Posted September 28, 2009 Hi I have created a log in site for a service but the service only works for IE version 6 and up. I want the client to get a pop up if they are using a different browser or version. The first page contains a log on link that takes the user to a log in page where they fill out username and password. I want the error message to pop up when they get to this page. I have found a javascript on w3schools but it doesn't work as its supposed to. On w3 schools it said: "IMPORTANT! The version number is WRONG in IE 5.0 or later! Microsoft starts the appVersion string with the number 4.0. in IE 5.0 and IE 6.0!!! Why did they do that??? However, JavaScript is the same in IE6, IE5 and IE4, so for most scripts it is OK." http://www.w3schools.com/js/js_browser.asp The script: <html><head> <script type="text/javascript"> function detectBrowser(){ var browser=navigator.appName; var b_version=navigator.appVersion; var version=parseFloat(b_version); if ((browser=="Microsoft Internet Explorer") && (version=5)) { alert("OK"); } else { alert("Wrong browser or version!"); }} </script></head> <body onload="detectBrowser()"> </body></html> Is it possible to make som changes to this script to make it work? Iv tried to use http user agent but this only blocks firefox, and not opera and IE . Is it easier to user "user agent"? If so how do i block opera as well as firefox? Thankful for any tips Quote Link to comment Share on other sites More sharing options...
haku Posted September 28, 2009 Share Posted September 28, 2009 You can do this without javascript using conditional comments. Quote Link to comment Share on other sites More sharing options...
LMarie Posted September 28, 2009 Author Share Posted September 28, 2009 Great.. It works. Thank you Much easier too. The script i used: <html> <head> <![if !IE]> <SCRIPT LANGUAGE="Javascript"> alert("You need to use IE 6 or above to get access to this service"); </SCRIPT> <![endif]> <!--[if lte IE 5]> <SCRIPT LANGUAGE="Javascript"> alert("You need to use IE 6 or above to get access to this service"); </SCRIPT> <![endif]--> </head> </html> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.