How to prevent IE from opening my page in compatibility mode? - html

I have this html/jsp page:
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html ...
</html>
which, for some reason, is opened by default in compatibility mode on IE (in my case version 10) and this messes up everything as it just does not understand some modern constructs present in libraries such as angularjs.
By opening developer's tools and changing the view mode to "standard IE" everything fixes up and my web application works fine.
So, what's wrong with this header? Is there a way to force IE to open my page in normal mode?
This question is more or less the same of this one, I know that:
Why Does IE-8 push the view to Compact/Compatibility view?
but I don't want to force my user to open tools and set options like correct marked answer suggests: most of them are just ignorant, many of them have developers tools disabled on their company's PC.
In the end just want to see where's the problem with my web application and make so that IE accepts it as a normal page.

insert meta tag in header HTML:
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
The "edge" forces standards mode (or latest rendering engine) in IE.
To force IE8 to standard mode.
<meta http-equiv="x-ua-compatible" content="IE=8">

Related

How to force IE11 Compatibility Document Mode to be 8? [duplicate]

This question already has answers here:
IE10 renders in IE7 mode. How to force Standards mode?
(5 answers)
Closed 7 years ago.
I am a developer on a web app that only works in IE11 if it is added to compatibility view(defaulting the document mode to 5). The problem is that there is a page within the web app that needs CSS :before which does not work correctly if the document mode is below 8. I've tried adding
<!DOCTYPE html>
and
<meta http-equiv="x-ua-compatible" content="IE=8" >
But the page seems to be defaulting that page to document mode 7. I'm not too familiar with how IE works but is there any way around this?
If you're trying to avoid Compatibility mode, you need to specify it as follows:
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
The "Edge" mode tells IE to use the best available mode; thus IE11 should use IE11 mode.
If you're still getting stuck in the wrong mode, there are a few other things to check:
Make sure your HTML code is valid and starts with <!DOCTYPE html>. Invalid HTML or a missing doctype is likely to trigger IE to fall back into IE5 mode (also known as Quirks mode). This will clearly break most of the code for pretty much any modern site.
Check your browser and network settings; IE can be configured to override the compatibility settings and always put certain sites into compatibility mode. Typically this is for sites on the local network.
You can use the emulate option:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />

IE11 browser showing document mode as 5(default)

Im using bootstrap framework and using the follwoing docttype and meta tag.
<!DOCTYPE html>
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
Here IE showing document mode as 5(default), mean while all the UI got disturbed, any solution for showing IE=edge.
Thanks
Your IE options are probably set to display Intranet sites in Compatibility View. I tested IE 11 at the official Bootstrap site and it was set to Edge using X-UA meta tag.
From the MS documentation:
Via intranet compatibility settings: The "Display intranet sites in Compatibility View" box is checked in the Compatibility View settings."

How to force IE10 to render page in IE9 document mode

I have two questions:
How can I force IE10 to render in IE9 document mode? Currently it's rendering my page in Standard document mode.
In IE10's developer toolbar, I am not able to see the option of document mode of IE10. Is it not implemented, or is my browser version is out of date?
Thanks for all your help.
Edit: thanks everyone for the solutions provided. Earlier I was using a meta tag
<meta http-equiv="x-ua-compatible" content="IE=edge" >
just to make sure that IE will render the page in highest document mode, but I was facing some issues with IE10 standard mode, so I changed the meta tag to render the page in IE9 mode:
<meta http-equiv="x-ua-compatible" content="IE=9" >.
You should be able to do it using the X-UA meta tag:
<meta http-equiv="X-UA-Compatible" content="IE=9" />
However, if you find yourself having to do this, you're probably doing something wrong and should take a look at what you're doing and see if you can do it a different/better way.
Do you mean you want to tell your copy of IE 10 to render the pages it views in IE 9 mode?
Or do you mean you want your website to force IE 10 to render it in IE 9 mode?
For the former:
To force a webpage you are viewing in Internet Explorer 10 into a particular document compatibility mode, first open F12 Tools by pressing the F12 key. Then, on the Browser Mode menu, click Internet Explorer 10, and on the Document Mode menu, click Standards.
http://msdn.microsoft.com/en-gb/library/ie/hh920756(v=vs.85).aspx
For the latter, the other answers are correct, but I wouldn't advise doing that. IE 10 is more standards-compliant (i.e. more similar to other browsers) than IE 9.
You can tweak the Registry if you want to make changes only to your own system. If you have IE10 and lots of web sites you visit don't render properly in IE10, then you can tweak your registry to force IE to open in IE9 mode.
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION
Create a DWORD as iexplore.exe and give value 9999. Restart your IE and it will open in IE9 mode :)
Thanks to my colleague Sreejith D :)
I haven't seen this done before, but this is how it was done for emulating IE 8/7 when using IE 9:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9">
If not, then try this one:
<meta http-equiv="X-UA-Compatible" content="IE=9">
Add those to your header with the other meta tags. This should force IE10 to render as IE9.
Another option you could do (assuming you are using PHP) is add this to your .htaccess file:
Header set X-UA-Compatible "IE=9"
This will perform the action universally, rather than having to worry about adding the meta tag to all of your headers.
By what this says, IE10 (the article is referred to a preview release, anyway) it's able to use X-UA-Compatible only if the document is in quirks mode (no DOCTYPE), otherwise IE10 won't react to the request.
Here's an excerpt:
Thus, to make IE10 react to the X-UA-Compatible directive, one must either create a page that triggers quirks-mode per the rules of HTML5 (that is: an a page with no doctype). One can also send the directive as a HTTP header, however: A HTTP sent directive appears to have no effect if you use it to downgrade the rendering — it can only be used to upgrade the rendering
So, you've to do it manually with Dvelopers Tools, or with quirks mode (but I suggest to stay in IE10 mode which is for the first time aligned to the other browers' standard)
EDIT: The follows are some useful link to read:
http://msdn.microsoft.com/en-us/library/cc288325(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/jj676915(v=vs.85).aspx
http://blogs.msdn.com/b/ie/archive/2011/12/14/interoperable-html5-quirks-mode-in-ie10.aspx
You can force IE10 to render in IE9 mode by adding:
<meta http-equiv="X-UA-Compatible" content="IE=9">
in your <head> tag.
See MSDN for more information...
there are many ways can do this:
add X-UA-Compatible
tag to head
http response header
using IE tools F12
change windows Registry
The hack is recursive. It is like IE itself uses the component that is used by many other processes which want "web component". Hence in registry we add IEXPLORE.exe. In effect it is a recursive hack.
I found this post while I was looking for a solution to my DNN6 website.
The error was
SCRIPT5007: Unable to get property 'documentElement' of undefined or
null reference
But I needed the same solution: force compability mode to IE9. So let me share with you what I did to solve this.
So, for DotNetNuke 6 users try the StyleHelper SkinObject
Worked great for me!

Why does IE9 opens in Document Mode as IE7 standards?

When I open a webpage in IE9 with DOCTYPE as
<!DOCTYPE html>
It opens Document Mode as IE7 standards.
I need default IE9 standards on opening the page.
How to correct this document mode problem?
A screenshot of how it comes in IE browser developer tool
Try this answer: https://stackoverflow.com/a/13524518/1679310.
Summary, give the IE browser more information in the meta tag:
<!DOCTYPE html>
<html>
<head>
<title>My Web</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
Edit Note: As Olly Hodgson mentioned, the proper option is IE=edge, as currently stated in the above snippet. Below is the original, also working version:
<meta http-equiv="X-UA-Compatible" content="IE=100" />
There can be multiple reasons why it could be parsing the document under IE7 standard:
The server is sending a X-UA-Compatible header for IE7 in the HTTP response of the document. Check the server response headers using a tool like Fiddler.
The HTML document is setting a meta tag with the X-UA-Compatible property value for IE7.
The page is being detected automatically by IE for opening in "Compatibility view". Note here that by default all intranet sites are viewed in "Compatibility view" in IE. Uncheck the checkbox "Display intranet sites in Compatibility view" under Tools -> Compatibility view settings in IE. The "Display all websites in Compatibility view" should be unchecked too.
You used the Developer tools and explicitly set to view the page to render in "IE7 standards" mode. Note that this will only occur on a per client basis though.
Update 2016-01-28
As #Gordon pointed out in the comments below, another reason can be that the network administrator has set the site for compatibility view as a Group Policy on the network.
The only resolution in that case is to contact the network administrator to remove the site from the Group Policy. See HTML1203 here.
You can set this in the web.config as well.
<system.webServer>
<httpProtocol>
<customHeaders>
<clear />
<add name="X-UA-Compatible" value="IE=edge" />
</customHeaders>
</httpProtocol>
Does your page contain the meta tag for forcing IE7?
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
this will force the page to use IE7 compatibility.
Just wanted to share that if your web server is Apache2 you could set the Response header like below in your VirtualHost configuration which will also resolve the issue.
Header set X-UA-Compatible "IE=edge"
The issue appears to be specific to the combination of IE9 and compatibility mode. For us, we cannot disable compatibility mode since it is a SharePoint 2013 site and IE11 must run in compatibility mode to edit pages, but IE9 was behaving as you are showing. Setting the X-UA-Compatible to "IE=edge" in a meta tag did fix our issue, although setting the value to IE=10 did not affect our behavior. We also have the same doctype.
If your project is ASP.NET MVC, make sure that you add the:
<meta http-equiv="X-UA-Compatible" content="IE=edge">
tag into your Layout (template) page. I just spent two hours debugging and tweaking, only to realize that I had only added that meta tag into my child pages. As soon as I added it to my layout page, the browser loaded in EDGE mode perfectly.

Forcing Internet Explorer 9 to use standards document mode

How can I force Internet Explorer 9 to use standards document mode? I built a website and I'm finding that IE9 uses quirks mode to render the website pages. But I want to use standards mode for rendering.
<!doctype html>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
This makes each version of IE use its standard mode, so IE 9 will use IE 9 standards mode. (If instead you wanted newer versions of IE to also specifically use IE 9 standards mode, you would replace Edge by 9. But it is difficult to see why you would want that.)
For explanations, see http://hsivonen.iki.fi/doctype/#ie8 (it looks rather messy, but that’s because IE is messy in its behaviors).
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
The meta tag must be the first tag after the head tag or it will not work.
There is something very important about this thread that has been touched on but not fully explained. The HTML approach (adding a meta tag in the head) only works consistently on raw HTML or very basic server pages. My site is a very complex server-driven site with master pages, themeing and a lot of third party controls, etc. What I found was that some of these controls were programmatically adding their own tags to the final HTML which were being pushed to the browser at the beginning of the head tag. This effectively rendered the HTML meta tags useless.
Well, if you can't beat them, join them. The only solution that worked for me is to do exactly the same thing in the pre-render event of my master pages as such:
Private Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
Dim MetaTag As HtmlMeta = New HtmlMeta()
MetaTag.Attributes("http-equiv") = "Content-Type"
MetaTag.Attributes("content") = "text/html; charset=utf-8;"
Page.Header.Controls.AddAt(0, MetaTag)
MetaTag = New HtmlMeta()
MetaTag.Attributes("http-equiv") = "X-UA-Compatible"
MetaTag.Attributes("content") = "IE=9,chrome=1"
Page.Header.Controls.AddAt(0, MetaTag)
End Sub
This is VB.NET but the same approach would work for any server-side technology. As long as you make sure it's the last thing that gets done right before the page is rendered.
put a doctype as the first line of your html document
<!DOCTYPE html>
you can find detailed explanation about internet explorer document compatibility here: Defining Document Compatibility
To prevent quirks mode, define a 'doctype' like :
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
To make IE render the page in IE9 document mode :
<meta http-equiv="x-ua-compatible" content="IE=9">
Please note that "IE=edge" will make IE render the page with the most recent document mode, rather than IE9 document mode.
Make sure you take into account that adding this tag,
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
may only allow compatibility with the latest versions. It all depends on your libraries
I tried with an alternate method:
Hit F12 key
Then, at right hand side in the drop down menu, select internet explorer version 9.
That's it and it worked for me.
Make sure you use the right doctype.
eg.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
or just
<!doctype html>
and also read and understand how compatibility modes and developer toolbar for IE work and set modes for IE:
I have faced issue like my main page index.jsp contains the below line but eventhough rendering was not proper in IE. Found the issue and I have added the code in all the files which I included in index.jsp. Hurray! it worked.
So You need to add below code in all the files which you include into the page otherwise it wont work.
<!doctype html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
</head>