Disappointment: Cannot force IE 8 into "Compatibility View"!

I have two different sites. Both of them have different errors when displaying "Internet explorer 8" in browser mode!

When you click the Compatibility button next to the address bar, both sites look great. When I later look at “Browser Mode” and “Document node” using the built-in “Developer Tools”, I also notice that “Browser Mode” is “IE8 View” and “Document Mode” is IE7 Standards. Also, as I expect them to be.

Then I want to get Internet Explorer 6 to go to Browser Mode: View IE8 Compatibility, so that my users don’t have to click the Compatibility button next to the address bar to get what they really need to see.

The only way I can do this is to insert a meta tag under the heading inside the heading as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <title>Test</title> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> <meta http-equiv="Content-type" content="text/html;charset=UTF-8" /> <link ... /> <script ...></script> </head> <body> ... </body> </html> 

Then I reload the website and the "Compatibility" button disappears next to the address bar. As expected. When I then look at “Browser Mode” and “Document node” using the built-in “Developer Tools”, I suddenly see what I really did NOT expect. I was expecting “Browser Mode” to be “IE8 View,” and “Document node” to “IE7 Standards,” but “Browser Mode” to “IE8,” and “Document Mode” to “IE7 Standards,” and sites suddenly There is a new set of errors compared to viewing in Internet Explorer 8 browser mode.

It’s unfortunate why I can’t get the browser to use the IE8 View browser mode instead of the Internet explorer 7 or Internet explorer 8 browser modes?

+6
internet-explorer-8 compatibility view
source share
8 answers

In specify IEBlog :

"Browser mode" affects the user agent string, the version vector used when evaluating conditional comments and the rendering mode.

This is described in detail at http://msdn.microsoft.com/en-us/library/dd565624(VS.85).aspx .

As you can see clearly, you still cannot influence all these things: by the time you tell the browser to act like IE7, it is already acting like IE8.

Perhaps the real question is: Why is browser mode so important to you? Document mode is what bothers you the most - everything that the browser mode changes as long as those related to rendering are related to what is excluded / enabled but verified by the version, and users will still not search in the developer tools therefore they don’t care.

Instead of spending a lot of time making it look like a clean compatibility mode in the developer tools, you should go and make sure that the user agent string check and conditional comments make it so that IE7 and IE8 get the same stuff to work with, then leave EmulateIE7 in.

EDIT:

The problem is checking your version, and as I said below, I will tell you where the problem is.

If you use the developer tools to debug the placement of the script menu, you can dig and see that the execution path for get_x_position is different when the browser reports itself as IE7 or IE8: is_ie5up set to true for IE7 mode and false for IE8 mode. This results in a return of very different values.

At this point, we should go back to where this variable is set:

 var is_ie5up = (is_ie6up || (is_ie && !is_ie3 && !is_ie4)); 

As you can see, this depends on the value of is_ie6up , so let's look at the surrounding code ...

 var is_ie8up = (is_ie8 || is_ie9up); var is_ie7up = (is_ie7 || is_ie8up); var is_ie7up = (is_ie7); var is_ie6up = (is_ie6 || is_ie7); var is_ie5up = (is_ie6up || (is_ie && !is_ie3 && !is_ie4)); var is_ie5_5up = (is_ie6up || (is_ie && !is_ie3 && !is_ie4 && !is_ie5)); 

... did you notice a flaw (hint: compare lines 2 and 4 of this snippet)?

This right: is_ie6up not set to true if the browser is not exactly IE6 or IE7. The correct line should of course read

 var is_ie6up = (is_ie6 || is_ie7up); 

... but wait. This is also not good, because line 3 of the fragment changes is_ie7up only like this: true, if the browser is exactly IE7! So, you need to delete the is_ie7up overwrite and fix the is_ie6up setting.

I assume that you have the EXACT same problem on another site: you have mixed up browser checks in much the same way.

+5
source share

You set the meta tag correctly, but IE8 seems to use the previous rendering mode until you restart the browser.

To find out what your users will see:

  • Click on Document Mode in the developer toolbar and see what value is checked (Page Default) .
  • Restart IE8 and view your document. Now IE should use the default page.
+2
source share

The xmlns = "http://www.w3.org/1999/xhtml" attribute cancels the meta tag. Move the meta tag above the html tag. Yes, that’s right, above the html tag. He will then run emulateIE7 before running javascript. I tested this in IE7, IE8 and Firefox.

+1
source share

In my specific case, my site will not be displayed properly in the "Share View" view. Finally, I found out that browser mode affects the User Agent line. My site style rules were based on the User Agent, so some styles just didn't apply in the Compatibility view.

I used

  document.documentElement.setAttribute ('data-useragent', navigator.userAgent); 

so that later I can use the css attribute selector like

  html [data-useragent * = 'MSIE 8.0'] p {} 

I decided by adding:

  html [data-useragent * = 'MSIE 7.0'] p {} 

(not caring about true IE7, since true IE7 was not supported)

In my experience, a developer cannot do anything to force IE8 to “Browser Mode: View IE8 Compatibility” to “Browser Mode: IE8”. Again, I'm talking about BrowserModes NOT DocumentModes (which can be controlled by meta tags, response headers, etc.).

+1
source share

Not a problem that you are using the wrong type of document?

May be:

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 

See http://htmlhelp.com/tools/validator/doctype.html for more information.

0
source share

I was converting an XML document, so I could not set DOCTYPE correctly. Instead of moving above <html> , which is invalid XML, I just put it in the header.

In PHP:

 header("X-UA-Compatible: IE=7"); 
0
source share

There was a problem with forcing IE8 in IE8 standards in document mode using the HMI5 Boilerplate for the classic asp site. By combining the answers to this and other questions, adding this code ABOVE, the <doctype> seems to have solved the problem and forcibly moved the document mode from IE7 back to IE8. <%= response.AddHeader("X-UA-Compatible", "IE=edge") %>

0
source share

If your page contains ASP.NET Ajax stuff, you may need to refresh your site using this

http://support.microsoft.com/kb/2600088

0
source share

All Articles