Click to See Complete Forum and Search --> : HELP! Need Browsercheck for IE5.5


fkn
03-07-2003, 08:49 AM
Can somebody help me with this:

I need to redirect IE 5.0 and lower browsers to one html-page, and IE 5.5 and higher browsers to another html-page.

How am I supposed to distinguish IE5.0 AND LOWER, from IE5.5 AND HIGHER in the Java script.

Here is the code that I´m trying to use:
----------------------------------------------------------------------
<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin

var name = navigator.appName;
var vers = navigator.appVersion;
vers = vers.substring(0,1); // or 0,4 could return 4.5 instead of just 4

if (name == "Microsoft Internet Explorer")
url="msie";
else
url="netscape";
url += vers + ".html";
document.write('<center>');
document.write('<A HREF="' + url + '">Enter</A>');
document.write('</center>');

// You may make the redirection automatic by using this
// window.location=url;
// instead of the three document.write lines above

// End -->
</script>

gil davis
03-07-2003, 10:23 AM
For IE 5.5, navigator.userAgent contains:Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; T312461)and navigator.appVersion contains:4.0 (compatible; MSIE 5.5; Windows NT 5.0; T312461)You should be able to detect IE 5.5 by using:is_ie55 = (navigator.appVersion.indexOf("MSIE 5.5") != -1);

fkn
03-07-2003, 11:08 AM
But... I am new at this...

How do I apply this to the script so that earlier browsers than ie5.5 are redirected to another page?

pyro
03-07-2003, 11:24 AM
This will check if it the browser is IE and if the version is less than 5.5:

<script language="javascript" type="text/javascript">

var pos = navigator.userAgent.indexOf('MSIE');
var bVer = navigator.userAgent.substring(pos + 5);
var pos = bVer.indexOf(';');
var bVer = bVer.substring(0,pos);
var bName = navigator.appName;

if (bName == "Microsoft Internet Explorer" && bVer < 5.5) //if IE 5.5 or less
{
window.location = "someotherpage.htm";
}

</script>

fkn
03-09-2003, 06:13 PM
It solved my problem!

I think I´m beginning to understand how this works!