Search code examples
phpjavascriptmeta

Stop ie 9 using compat mode because of js injection


Hi All Hope you can help,

I am manipulating a cms using server side php (phpQuery Library) which is injecting some minimised js into the header of a HTML page.

My problem is that I want to add meta tags to force ie9 to use standards mode. However when I inject the meta tags with php, the javascript injected after is forcing my meta tags downs and setting ie9 into compat mode.

I have have no control of the injection javascript, but can add my own scripts if this would work.

On looking at view source and inspect element when debugging I can see the js loaded on the page is forcing the meta tags down.

Could I use my own js to get them back up? I was under impression that meta tags need to be set before page load ie server.


Solution

  • To create a webpage that is displayed in standards mode when viewed with Internet Explorer, use the HTML5 document type directive, as shown in the following code example:

    <!DOCTYPE html>
    <html>
    <head>
      <title>Enabling Standards Support</title>
    </head>
    <body>
      <p>
         Because this webpage uses the HTML5 document 
         type, it is displayed in IE9 Standards mode.
      </p>
    
    </body>
    

    So your JS should only be added after the

    <!DOCTYPE html>
    

    is declared.

    If your webpage does not include a !DOCTYPE directive or if it specifies a non-standards mode document type, Internet Explorer displays your webpage in IE5 (Quirks) mode. When this happens, Internet Explorer ignores features in your webpage that require standards mode.

    REF : http://msdn.microsoft.com/en-us/library/ie/gg699338(v=vs.85).aspx