Saturday, July 9, 2011

Internet explorer 9 always in quirks mode for local files

While working on canui, I was trying to check some examples with internet explorer 9. These examples were on my local apache server. After getting some errors about the canvas object, I opened up the developer tools (in the sprocket icon) and noticed the "document mode" was in "quirks mode."

I first realized that I hadn't included a doctype declaration. The HTML5 doctype is simply

<!DOCTYPE html>

However, even with the doctype, the page was still staying in quirks mode. Pages like the fish test were working fine. When I noticed that my examples were working fine from sourceforge, my google searches changed from "always in quirks mode" to "quirks mode localhost" and I quickly found a KB article about compatibility view.

After feeling like an idiot for a few seconds about not finding the "compatibility view settings" item in the sprocket menu, I stopped looking at the images and started reading the actual text and understood that the Tools menu is not the sprocket menu. Pressing alt brings it up. I blame the lack of coffee at that time.

In the compatibility view settings, there is a checkbox "Display intranet sites in compatibility view" that is checked by default. Unchecking it fixes problem.

Therefore, make sure:
  1. the html page starts with <!DOCTYPE html> but without anything before it, including a BOM mark;
  2. the compatility view settings (in the Tools menu) for local files is unchecked;
  3. you're not forcing any specific document mode in the developers tools;
  4. you're not using any kind of X-UA-Compatible meta tags;
  5. the windows group policy isn't forcing compatibility mode.

No comments: