0

To force a web page to open in standards mode I believe I need to add the following meta tag to the head section.

<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">

I also read at some places that some other tags might get added before the meta tag and therefore this might not work. Therefore the HTTP response header needs to be set and that should work. I did that too and verified with the IE developer tools that the response now contains the header "X-UA-Compatible" with the value "IE=Edge,chrome=1" (can't upload a screenshot, not enough reputation)

However the Browser Mode is still IE9 Compat View and the Document Mode is IE8 standards. Is there anything more I need to do?

Following is the html snippet

<!DOCTYPE html>
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO 8859-1"%>
    <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
    <%
        String contextPath = request.getContextPath();
    %>
    <html>
        <head>
            <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
                .
                .
        </head>
    </html>
  • If it's an intranet-site, IE automatically jumps into CompatMode – Sebastian G. Marinescu Apr 25 '14 at 10:49
  • Is there any way I can over ride this? Because I am working on the intranet. – user1251310 Apr 25 '14 at 12:40
  • Please check [this SO answer](http://stackoverflow.com/a/13287226/1169519). – Teemu Apr 25 '14 at 12:42
  • @Teemu thanks for that. By turning off compatibility for for intranet sites I was able to get the browser mode to IE9. But the documents mode is still stuck at IE8 standards. I can verify with the F12 developer tools that when the web page loads the response has the header "X-UA-Compatible" with "IE=edge,chrome=1" as the value. – user1251310 Apr 25 '14 at 12:50
  • The `X-UA` has no affect, if anything before it defines the document mode, like `script`, `link` or `style` tag (or actually the code they load/contain). IE is also very bad to parse invalid HTML, have you [validated](http://validator.w3.org/#validate_by_input) your code? – Teemu Apr 25 '14 at 12:58
  • check your HTTP Headers, you can do that in the F12 tools network tab. If the server is sending an X-UA-Compatible header that overrides the META tag. Also make sure you have and not an outdated DOCTYPE. – Chris Love Apr 26 '14 at 04:54

1 Answers1

1

Be sure you have a valid doctype, and that there are no spaces before the doctype. Also, the <html> tag should not have any xmlns atribute, like xmlns="http://www.w3.org/1999/xhtml" , if you use the HTML5 doctype

<!DOCTYPE html> 
    <html> 
        <head> 
        ...
Corneliu
  • 1,110
  • 1
  • 10
  • 16
  • 1
    *In HTML documents, elements in the HTML namespace may have an `xmlns` attribute specified, if, and only if, it has the exact value "`http://www.w3.org/1999/xhtml`".* — http://www.w3.org/TR/html5/dom.html#global-attributes – Quentin Apr 25 '14 at 10:38
  • <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> <% String contextPath = request.getContextPath(); %> – user1251310 Apr 25 '14 at 12:30
  • I'm sorry I really couldn't formal the above piece of html. I will edit and add it in the question. – user1251310 Apr 25 '14 at 12:34