14

We have a parent page that must run in IE9 standard mode, executing HTML5 commands. Underneath we have an iframe that must run in compatibility mode (IE7/8).

In IE9, as I understand, iframes inherits their doctype from parent. is that correct? Is there any solution for this issue? can , somehow, iframe be executed with quirks doctype under standard mode doctype parent frame? thanks, Tal

Tal
  • 1,773
  • 4
  • 18
  • 20
  • See this answer -> http://stackoverflow.com/a/5624373/572939 – Manse Jul 30 '12 at 14:41
  • possible duplicate of [Run quirks mode in one frame and standards mode in another?](http://stackoverflow.com/questions/4902255/run-quirks-mode-in-one-frame-and-standards-mode-in-another) – Diodeus - James MacFarlane Jul 30 '12 at 14:41
  • 1
    These do not provides answers - since it forces the whole page running in IE7 mode. The required behavior is to enable IE9 mode in parent, yet quirks mode in iframe inside. – Tal Jul 30 '12 at 14:46
  • Can you just use some normalization techniques to fix the ugliness that the child iframe bleeds into its parent? E.g. http://necolas.github.com/normalize.css/ ? – Noyo Mar 24 '13 at 13:25
  • I did extensive research on this some time back for a project (more links than I care to post here). My conclusion: there is absolutely no way to do it, and it would solve a lot of problems if there were. That being said, it's possible (I don't know your use case) to achieve a similar result using VB.NET and WebBrowser controls, if that's part of your tech stack. – Sean Mar 25 '13 at 13:49
  • take a look at: https://stackoverflow.com/questions/12467151/iframe-not-rendering-in-ie9-mode-when-containing-page-is-in-quirks-mode – A. Binzxxxxxx Oct 02 '14 at 16:47

1 Answers1

27

It's not possible to trigger a different rendering mode in a child iframe in IE9, as officially documented here: http://msdn.microsoft.com/en-us/library/gg558056(v=vs.85).aspx (emphasis added):

Although the newer rendering engine is only used when Windows Internet Explorer detects that an HTML page has requested the highest level of support for standards, the same is not always true for child pages that might be loaded within frame and iframe elements. Because only one rendering engine can be active at a time, IE9 Mode also includes emulation for Quirks Mode.

However, as it says, you can trigger "quirks mode emulation" which leaves the IE9 rendering engine active but alters its behavior in several ways to match the old quirks mode.

JSBin demo: http://jsbin.com/ozejuk/1/

This example has a div with style background: #ff0000; background: 00ff00; border-radius: 30px ... in quirks mode, hex colors without # are accepted. In IE9 mode they are not. Loading the demo in IE9 will show a red div in the parent page, and a green div (but still with rounded corners) in the iframe.

How to trigger quirks mode emulation in an iframe: http://msdn.microsoft.com/en-us/library/gg558096(v=vs.85).aspx

Short version: omit DOCTYPE, add: <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

Complete list of effects quirks mode emulation has on rendering: http://msdn.microsoft.com/en-us/library/gg558047(v=vs.85).aspx

  • Thanks for the response, Nick. I'll look into it later today or next week. – isherwood Mar 22 '13 at 14:19
  • Unfortunately, emulating quirks mode doesn't appear to resolve my issue, which is this: https://bugbase.adobe.com/index.cfm?event=bug&id=2928139 Thanks again for the reply. I appreciate the effort you put into it. +1. – isherwood Mar 22 '13 at 19:53
  • Apparently in IE10+ you can trigger different rendering mode in a child. see http://stackoverflow.com/questions/26206688/ie11-quirks-mode-under-iframe-javascript-errors/41270772#41270772 – John Henckel Dec 21 '16 at 21:01