Compatibility issue in IE8 - ASP.NET MVC 3.0 intra application - html

We have been developing ASP.NET MVC 3.0(Razor & HTML 5) application with IIS 7.5. The site should run on IE8.
The site content displays properly when the comaptibility mode is OFF. But, if it runs with compatibility mode on then the few elements goes outside horizontally.
As the company's IE policy, all the intranet application runs under the "Compatibility Mode" hence I can't change that part.
What should be possible solution?
1. Is there any way when the application url gets renedered, I explicitly instruct browser to not run under compatibility mode (programmatically)?
2. Is there any ways in IIS 7.5 to enforce rendering targeting IE 8.0+?
3. Do I need to target to HTML 4.0 and convert all the fuzzy css/html targeting older html version?
I am seriously out of idea. It may possible the above direction points are also logic-less.
Please suggest somthing on this.

You'll need to set the X-UA-Compatible header. You can do in at least two ways:
Add the following to every page:
<meta http-equiv="X-UA-Compatible" content="IE=8" />
Or you can tell IIS to send it with every response following these instructions to set custom headers to every response.
For a list of values you can use X-UA-Compatible look at this page.

Add this <meta> tag inside <head>:
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
This should force IE to use the most up-to-date rendering engine available.

Related

CSS Pie & IE Meta Tag

I've been using CSS3 Pie on my site with great success. I recently had a Jotform form with a custom CSS button with radius, Pie doesn't work with Jotform so I came across this meta tag
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
which when added to the particular page resolved the radius issue in IE8.
My question is this, if it's this simple to allow older versions of IE to render modern CSS can this tag be utilized as default and if not why not i.e bad practice, technical reasons etc.
It seems to good to be true so I'm guessing there has to be a reason, I'm aware it doesn't validate but to avoid this it can be added to an .htaaccess file.
This meta tag is needed to prevent IE8—10 from switching to Compatibility mode (which means more or less emulation of the IE7 renderer). In most cases, it's a good practice to use the latest available rendering engine, so it's better to keep this meta tag.
Also, be sure that pages have the proper Doctype (<!DOCTYPE html> will be enough for almost all practical applications), so other browsers also could display them using the newest rendering mode, according to the latest standards that browsers can support.
!-- Force IE to use the latest version of its rendering engine -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
The above meta tag is used to force IE to use the latest version of its rendering engine.
In case if user opens in IE8 browser with IE8's default rendering engine? This will certainly fails. Therefore it is good to use CSS3PIE along with this meta tag.
You can check this in MSDN Library.

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!

Does the requiresActiveX=true meta tag actually work?

I've read a bunch of blog posts, like this one, and also some other questions here on SO, like this one.
These all say that if you want to popup a message advising the visitor that the Desktop mode of IE 10 is required to view the site, then 'all you have to do' is add this meta tag:
<meta http-equiv="X-UA-Compatible" content="requiresActiveX=true" />
Or you can set an HTTP header instead:
<add name="X-UA-Compatible" value="requiresActiveX=true" />
I've tried both of these techniques and neither of them seem to work! The Modern UI version of IE just does nothing at all. No popup, no message, nothing.
I'm running my site locally at the moment through IIS 8. I've added the URL to my trusted sites list. If I use another browser, like Chrome, I can see that the response header is definitely being set. The page runs in IE10 Modern, it just doesn't tell me to switch to Desktop mode...
I've tried strategically positioning the <meta tag in different places in the <head etc but this has not helped either
Can anyone offer any advice? Even mentioning a site that implements it would help...
Edit
I've tried adding this to a 'live' web page on my own site and still I am not prompted to switch to desktop when using IE10 Modern...
Not sure this will address it for you but it did for me. I had to combine multiple Compat tags into a single entry. Lke this:
<meta http-equiv="X-UA-Compatible" content="IE=7, requiresActiveX=true"/>

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.

any side effect if I add ' <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">' on my page?

HTML5Boiler plate suggests we put this one in our HTML page if we favour Chrome over IE
(which is my case)
<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
We all understand how it works.
If the user is using IE but it has also installed the Chrome Frame the chrome frame will be used to run the page (which is probably much faster when it comes to execute my js)
The question: is there any 'bad' side effect ?
any particular reason why I should not add that snippet ?
Thanks
The only downside I know about this snippet is that validators don't accpet yet the content value of this meta (even if they should), so if it seems annoying to you, just remember you can also specify it inside an .htaccess (as suggested also on html5 boilerplate site)
See https://gist.github.com/1292092 for an example of htaccess inclusion
See also this thread about meta validation
This does not have any downsides.
This will force the browser to render as properly as it can, ignoring those awful IE Compatibility modes.
This will not break the browser, just peacfully explain to it, that this page doesn't wish to be experimented with, and just to be shown properly.
There are in fact downsides to this meta tag (along with conditional comments) which is why we recommend you reference it from the server. See this issue for details.