我可以只对 <frame> 中的内容禁用 IE 兼容模式吗?

Can I disable IE compatibility mode only for content within a <frame>?

我开发了一个在公司内部网上运行的 Web 应用程序。我在之前的过程中遇到了 Internet Explorer 的自动兼容模式问题,并添加了代码以强制我的页面在最新版本的 IE 中显示:

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

这非常有效。直到我的 Web 应用程序最近被集成到另一个 Intranet 中,我们的客户也可以使用它。网页是我无法控制的。我的应用程序集成在另一个 html 页面的框架内。现在我回到了兼容模式,它破坏了我的网络应用程序的关键功能。

是否可以强制最新版本的浏览器只解释我框架内的内容?

根据 this & this(甚至比第一个更好 - 注意标记答案的人),解决方案是不可能的。

如果想一想,IE 的 GUI 实际上暗示整个页面以兼容模式呈现(每页只有 1 个指示器图标,在地址栏旁边),所以可以安全地假设所有内容都已处理相同。要么全页兼容,要么根本不兼容。

P.S。我知道这不是很有帮助,但它试图提供一个有效的理由说明为什么这是不可能的,最好开始从不同的方向寻找。就个人而言,我会尝试使用 HTML5 (<!DOCTYPE html>)。可以有选择地启用(仅在您的框架上)并且可能不会太难调整,因为您已经使用 'edge'...




此屏幕截图显示 IE 兼容性视图 可以 被托管框架覆盖。

框架在这里使用的技术是 (1) 将 X-UA-Compatible header 注入主机头,(2) 通过 document.write(),然后 (3) 重新加载主机页面。它具有将页面中的 all 帧提升到所选级别的效果。

online demo


Prior to putting googledrive into Compatibility View, you'll notice the demo menu has no effect.  It is unable to override any mode IE9 or higher, as they are "locked". IE8, IE7, and IE5 modes (and thus CV) are "unlocked" and can be overridden.  That's the basis of the trick.

On the other hand, this following demo's Host page contains an X-UA-Compatible IE=5 (aka Quirks) header to start with.  So the frame is able to override the Host mode even without putting googledrive into Compatibility View.

online demo (Host XUA=IE5)


The concept here is derived from this MS-Connect 讨论 IE-modes 的线程在 iframe 中。