Saturday, 26 March 2011

SharePoint 2010 and IE 9

Microsoft has recently released IE9 to the Web, what would happen with your SharePoint 2010 UI and the UIs of custom apps built on top of it? The good news is SharePoint UI will work just fine with IE9, the bad news is some of my custom apps UI are messed up. Why SharePoint UI can maitain the compatibility but mine can't?
The asnwer is SharePoint renders X-UA-Compatible header in its html output. This header tells IE to render the UI with IE8 mode. It explains why. To fix my apps, it's simple enough, add the following header to the page
<html>
<head>
            <!-- Mimic Internet Explorer 8 -->
           <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" >
           <title>My webpage</title>
</head>
<body>
               <p>Content goes here.</p>
</body>
</html>
 Or modify web.config to specify Default Compatibility Modes

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <httpProtocol>
      <customHeaders>
        <clear />
        <add name="X-UA-Compatible" value="IE=8" />      </customHeaders>
    </httpProtocol>
  </system.webServer>
</configuration>


More information on IE Document compability at this MSDN article