0

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.

3
Contributors
6
Replies
22
Views
4 Years
Discussion Span
Last Post by cdoggg94
0

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]-->
0

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.

0

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.

0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.