Jump to content

ie 6 or less detection


Ninjakreborn

Recommended Posts

I can't give you a sure fire way to do so but here is the general method.

 

First, beware of any method that tells you to use the userAgent string.  Checking the userAgent string is often the quickest and easiest method but it is also unreliable since they can be faked.

 

The more proper method is to find a global variable or property that is specific to the browser in question and check for it's existence.  For example, IE has a global window.event object used for event-handling and they also have a document.all array.  I'm not sure when window.event was introduced, but for the sake of argument let's say it was at version 6.

 

This means if you wanted to check for IE 5.5 or lower you could do something like:

  if(document.all !== undefined){
    // We have an IE browser
    if(window.event == undefined){
      // IE 5.5 or lower
    }
  }

 

Again, I'm not saying the above code works or that those are properties you should be using.  I'm saying that's the general method for truly detecting which browser the user is using.

 

Using that knowledge and some google searching should land you with something you can use.

Link to comment
Share on other sites

You can use conditional comments, something like this

<script language="javascript">var isIE6 = false;</script>
<!--[if lte IE 6]>
<script language="javascript">var isIE6 = true;</script>
<![endif]-->
<script language="javascript">
alert(isIE6);
</script>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.