Detecting IE8 Compatibility View/Mode.

Posted on 2011-05-06
Last Modified: 2012-05-11

I'm trying to figure something out here.

I have:

<!--[if lt IE 8]>
According to the conditional comment this is Internet Explorer less than 8<br />

The problem is if IE8 is in compatibility mode/view it reports as IE7 and triggers this condition.  We're wanting to redirect anyone running IE7 or lower.

Is there anyways to determine if someone is running IE8 in compat mode and "return" it as IE8?  

I'm also trying to find a nice little script to determine if JS is enabled but that might be for a different post.  We're running Coldfusion 9 server if that helps.
Question by:gr1z
    LVL 81

    Accepted Solution

    Off topic but check this :
    LVL 28

    Assisted Solution

    Not sure if this will help or not, but I wrote a little JS that I embedded into a page that checks to see the version of IE that's running.  I'll attach the code below. Ignore the actual actions within the script, but see if the identifying line of code might get you what you need.
    <SCRIPT language="JavaScript">
    		var bname = navigator.appVersion;
    	if (bname.substring(22,23) == "7" || bname.substring(22,23) == "8")
         	setTimeout("'', '_self', '');window.close();",9000);
            setTimeout("window.opener = window;window.close();",9000);

    Open in new window


    Author Comment

    If there is a way to force our website to be viewed in IE8 Standard Mode that would work too.  I'm checking over what you guys have posted.

    There is one problem in IE7 otherwise we could allow both IE7 and IE8 compatibility mode/view.

    Author Comment

    Actually folks... We've resolved our issue in IE8 + Compat.  IE7 is still having issues but at least we're getting there lol.
    LVL 28

    Assisted Solution

    Glad you got that part fixed. I don't know how to force what you want. Was just sending the script as hopefully a way to identify version being used and then you'd have to go from there.
    I think the variable that's being looked at is hard-coded into IE and has nothing to do with compatibility mode.
    LVL 23

    Assisted Solution

    - see if this JavaScript helps. you just need to add the version condition to = 6, =7 to detect for each IE version:

    Featured Post

    Hire Freelancers to Complete JavaScript Projects

    Source the talented Expert Exchange community
    for top quality work on your JavaScript projects.

    Hire the best. Collaborate easily. Get quality work.

    Join & Write a Comment

    Suggested Solutions

    Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
    Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
    This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
    How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now