Cenzic 232 Patent
Paid Advertising
web application security lab

Detecting Default Browser in IE

unsticky sent over a nice snippet of code that helps identify if the user is using IE (of which there are dozens of ways to perform this task) and then, more importantly it can help you identify what is their default browser, if it’s not Internet Explorer using mimeType. A working proof of concept code is here. It works well detecting Firefox and Opera.

There does appear to be at least one false positive when using Netscape. If you are using Netscape in IE mode it will think you are using IE and will still report if that is not your default browser. However, I believe this code would also think your default browser is Firefox if you set it to Netscape since Netscape tends to use the Gecko rendering engine as it’s default (I haven’t tried, but that’s my theory). Anyway, cool snippet of code. Thanks, to unsticky for finding it!

6 Responses to “Detecting Default Browser in IE”

  1. Wladimir Palant Says:

    The value that IE reports there comes straightforward from the Windows registry - see the value of HKEY_CLASSES_ROOT\.html and look up the class with this name (HKEY_CLASSES_ROOT\FirefoxHTML for Firefox). The default value of this key is what IE reports there. Why you would give web pages this usually entirely useless information and then call it a *mime* type is completely beyond me. Compare with the document.contentType property in Gecko browsers. But I guess if you ask the answer will be as usually: “It’s not a bug, it’s a feature.”

  2. Jungsonn Says:

    very nice find indeed, especially to check if the browser is what it says it is, cause there are a bunch of Firefox ext. which mimic MSIE and Opera. It should not pass the test with this snippet, so very cool…. :)

  3. Jungsonn Says:

    I tried the User-Agent switcher on it, on all 3 browsers it still says I’m on Firefox, dispite the modified header, so it seems working.

    Cool stuff, a second thing I thought about using it for is to detect Robot activity, because while they can fake headers, they shouldn’t be able to fake this .

  4. Jungsonn Says:

    I found these BTW:


    I nver had to use these things, but they sure are interesting! :D

  5. RSnake Says:

    @Jungsonn - “new” browser age? Netscape 6? *cough* Where’d you dig that relic up from? ;)

  6. Jungsonn Says:

    Ghehe yeh your’e right this must be a clear case of “missing time” again, got I hate it when those alien entities obduct me again, I miss all the fun stuff, and leave me with iceage snippets :)