Today I got a requirement to put a check if person is not using Internet Explorer higher than 6 and Mozila Firefox higher than 2.5 , don't allow them to access the site since site is developed for IE ( version 6 or later) and Mozila (2.5 or later).

The first Easy stuff I did to test @BrowserInfo("Platform") and @BrowserInfo("Version")formulas in Explorer,Mozila and Safari. I saw strange stuffs, IE shows type "Explorer" and version 7 ( Which was right because I have version 7), but Mozila and Safari both shows type as "Mozila" and version 5, Whereas I am having Mozila 3 and Safari 3.2. Soon I realized this is not going to be a easy fix.

Next, I thought to check "The Navigator Object" which is having two property to detect browser type and version

appName - holds the name of the browser
appVersion - holds, among other things, the version of the browser

But as soon as tested found , wrong results again. Also found following warning in W3Schools ,

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.

Now what Next.. After spending couple of hours able to implement JavaScript which works well for all the browsers and provides correct type with version number. Here was my final JS code,




You just need to use in the JS file or JSHeader and call their methods like,



Since I can't post JS directly on the blog so posted as image, write me for JS code.

This tip is published in Search Domino website , Vote this tip if you like...

Leave a Reply

preload preload preload