Detect IE6

February 11, 2008

Since people keep looking for this, here is how you can identify IE 6 (and IE 6 only):

<script type="text/javascript">
var is_ie6 = (
	window.external &&
	typeof window.XMLHttpRequest == "undefined"

This is reliable and even Opera is not pretending to be IE6 with this check. This is mostly useful to determine whether the PNG/Alpha Image Loader hack needs to be applied.


The code provided by Lea Verou below performs up to 50% faster on all browsers except Firefox 2 and Google Chrome (where this test is really slow for some reason; maybe the in operator has not been optimized?)

<script type="text/javascript">
var is_ie6 = ('ActiveXObject' in window && !('XMLHttpRequest' in window));

I cannot wait for the day when we do not have to deal with IE6 anymore. Considering how many intranet applications exist that specifically target this browser, this day may be in a distant future, unfortunately.


5 Responses to “Detect IE6”

  1. Dima Sabanin Says:

    Doesn’t work for me, it returns true for FF3.0.1 on Mac.

  2. Lea Verou Says:

    I use something similar:
    if(‘ActiveXObject’ in window && !(‘XMLHttpRequest’ in window)) // do stuff

    Nice blog, keep it up! 🙂

  3. If you want to detect the Internet Explorers in WordPress:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: