Partager via


Update existing code to work across browsers

As you develop Internet Explorer apps, you must balance new features and functionality with site compatibility for existing webpages. Windows Internet Explorer 8 introduced document compatibility modes to help ease the transition from legacy implementations to the new standards.

This topic applies to all recent versions of Internet Explorer, starting with IE8, and Internet Explorer, starting with IE9. The info discussed here affects all document modes.

Guidelines

If you maintain an existing webpage that works correctly in Windows Internet Explorer 7 or Internet Explorer 8 and you want a short-term solution to enable the page to work in Windows Internet Explorer 9, you have two options:

  • Add a compatibility-mode meta element to each webpage to force Internet Explorer 9 to render the page similarly to your legacy Windows Internet Explorer page. (For more info, see How to Modify Each Page in the MSDN Library.)
  • Add the compatibility automatically by configuring your web server to send a custom HTTP response header that's equivalent to the meta element with each webpage. (For more info, see How to Configure the Server to Modify Each Page Automatically in the MSDN Library.)

Use these fixes only for quick, temporary use. Eventually, you'll want to modify your website to run standards-based code in Internet Explorer 9 and later versions and run legacy code for earlier versions of Internet Explorer.

Note  Starting with Internet Explorer 11, document modes are considered deprecated. Update all webpages and apps that require legacy document modes.

 

As a permanent solution, use feature detection to write code that reliably adapts to cross-browser differences. Feature detection tests whether a browser supports a feature before you use it, and behavior detection tests for known issues before you apply a workaround. For more info, see Use feature and behavior detection.

By adhering to these standards, your site will function well under legacy versions of Internet Explorer, Internet Explorer 9, and any future versions that are released.

How Do I Fix My Site Today?

Internet Explorer Compatibility

Version Vectors

What Will Windows Internet Explorer Report as the User-Agent String?