Javascript redirect based on browser type

hey guys, i’ve asked a question on the css forum and got great responses so here’s one on javascript.

i’ve been searching the net for a while for a javascript redirect so that i can redirect IE6 browsers to a page that asks them to update. i’m sure i’m not alone on here in wishing that all ie6 users would just update finally, but they haven’t yet. i’m also sure that i’m not alone in discovering that my site looks fine on all browsers but this one.

so my question is this, what’s wrong with my code? i found a few and this one seems to work best but it redirects IE7 as well. my code is this:

<script LANGUAGE=“JavaScript”>

function browser_check()
var name = navigator.appName;
var version = parseInt(navigator.appVersion);
go(name, version)

function go(name, version)
if(name == “Microsoft Internet Explorer” && version <=6)
location.href=“redirected url”

it redirects ie 6 and ie 7, but i only want it to redirect 6 and lower. why is my “less than or equal to” not working properly?

thanks in advance!

There’s no “perfect” way of checking for browsers but this one comes close:

thank jimmy, i’ve read through that and i hate to be this guy, but i’m really not versed well enough in javascript to interpret what they’re saying and then implementing it into reality.

with the code i’ve got now, it’s all working except for the browser version check. if i could just get that one bit sorted out…

print designers weren’t meant for this :lol:

haven’t figured out what’s wrong with my code, but i did find this website

http://www - dot -daobydesign - dot - com/blog/2007/06/detect-redirect-script-for-internet-explorer-ie/

it does exactly what i want it to do.

Why not use conditional comments?

function go(name, version)
   /*@if (@_jscript_version <= 5.6)
      location.href="redirected url";
   @else @*/
      // browser is > IE6 or other browser

that’s basically what this code i found does, only it does it through an external js file. but i will try your code next time i need to do this.