Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 828
  • Last Modified:

Detecting IE8 Compatibility View/Mode.


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.
4 Solutions
Off topic but check this : http://code.google.com/p/ie7-js/
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("window.open('', '_self', '');window.close();",9000);
        setTimeout("window.opener = window;window.close();",9000);

Open in new window

gr1zAuthor Commented:
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.
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

gr1zAuthor Commented:
Actually folks... We've resolved our issue in IE8 + Compat.  IE7 is still having issues but at least we're getting there lol.
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.
- see if this JavaScript helps. you just need to add the version condition to = 6, =7 to detect for each IE version:

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now