Basically we have a lot of people that want to view our site that use work computers and don't have the option to upgrade their browser. Most likely its an old version of IE.

All I want to do is detect if they are using something older then say IE 7. (we have tested with IE 7 and everything works fine on it)

If it IS older then that I want to send them to a dumbed down version of the pages.

I have looked up things like this:

http://www.quirksmod.../js/detect.html
http://api.jquery.com/jQuery.browser/

Which is fine, but I dont know how to simply send them to the right page.

I have done this sort of thing if they were using a mobile device like this:

<script type="text/javascript"> // <![CDATA[
    if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1)) {
        document.location = "http://www.Website.com/Mobile/";
    } // ]]>

        if ((navigator.userAgent.indexOf('iPad') != -1)) {
        document.location = "http://www.Website.com/Mobile2/";
    } // ]]>
</script>

Would it be the same type of thing but with the information in the detection script replacing the "iPhone", "iPad" ?

Any help would be great.

Thanks.

If you are only interested in detecting pre IE7, why not just use an IE conditional comment. If you detect "less than" IE 7, run a block of javascript to send the user to another page.

 <!--[if lt IE 7]>
      Special instructions for IE 7 or older here
  <![endif]-->

Thank you both the the input!

I'm looking into them now. I might reply once more with the solution I come up with to see if anyone thinks it's a good/bad way to approach this.

I tried something like this:

<script type="text/javascript">
function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}
function checkVersion()
{
  var msg = "You're not using Internet Explorer.";
  var ver = getInternetExplorerVersion();

  if ( ver > -1 )
  {
    if ( ver >= 9.0 ) 
      msg = "You're using a recent copy of Internet Explorer."
    else
      msg = "You should upgrade your copy of Internet Explorer.";
      window.location = "http://www.google.com/";
  }
  alert( msg );
}
</script>

I have tried it in a program called "IETester" and was testing with IE 8, 7, and 6.

It did not redirect, but it could have been the program.

Does this look like something that might do that ?

Before I added the window.location line though, the alerts were not working either.

Did you give the conditional comment approach a try. It would seem to be a simpler approach. You the only need to include your javascript redirect in the condition. It will only run if an IE browser comes a cross this code.

ok that seemed to be the answer.

Thank you very much !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.