IE9 中 iframe 内的 Javascript 版本
我有一个 Web 应用程序,它将 Outlook Web 应用程序放入 iframe 中。 这在大多数浏览器中工作得很好,但在 IE9 中失败,并在 Outlook 的 javascript 中出现错误:
SCRIPT438: Object doesn't support property or method '__defineGetter__'
uglobal.js, line 1 character 975667
似乎发生的情况是 __defineGetter__
函数已被弃用,并且在 IE9 中不存在,尽管大多数其他浏览器支持它。邮件应用程序通常在 IE7 标准模式下运行 - 如果我自己打开 Web 邮件并按 F12(开发工具),我会看到浏览器模式:IE9,文档模式:IE7 标准
并且没有任何问题。
但是,当我运行 iframe 中包含 Outlook 邮件的应用程序时,我看到浏览器模式:IE9,文档模式:IE9 标准
。这适用于外部站点,没有明显的方法可以找出 iframe 在 IE9 中的渲染方式。
框架源代码具有我期望的标头:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "ht`tp://www.w3.org/TR/html4/strict.dtd">
看起来 iframe 内的 JavaScript 正在运行,就好像它与版本无关一样。当然,它仍然是孤立的,所以我无法按照 这个黑客。
如何强制 iframe 内容在 IE7 模式下运行 JavaScript,与网站的其他部分不同?我们不想编辑 iframe 内的代码?我们不想这样做,因为它只是股票展望网络应用程序。如果我们确实必须去那里,我们只会修复他们的 JavaScript,而不是修复元数据。
I have a web application that puts the outlook web app inside an iframe.
This works quite well in most browsers, but it fails in IE9, with an error in outlook’s javascript:
SCRIPT438: Object doesn't support property or method '__defineGetter__'
uglobal.js, line 1 character 975667
What seems to be happening is that the __defineGetter__
function is deprecated and is not present in IE9, though most other browsers support it. The mail app usually runs in IE7 standards mode – if I open web mail on it’s own and press F12 (dev tools) I see Browser Mode: IE9, Document Mode: IE7 standards
and there are no problems.
However when I run the app that has outlook mail in an iframe, I see Browser Mode: IE9, Document Mode: IE9 standards
. That applies to the outside site, there's no obvious way to find out how the iframe is rendering in IE9.
The frame source has the headers that I would expect:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "ht`tp://www.w3.org/TR/html4/strict.dtd">
It looks like the JavaScript inside the iframe is running as if it's not as regards the version. Of course it’s still isolated so I can't monkeypatch this function in as per this hack.
How can I force the iframe contents to run JavaScript in IE7 mode, differently from the rest of the website? We don't want to edit the code inside the iframe? We don't want to do that since it's just stock outlook web app. And if we do have to go there, we would just go for fixing their JavaScript not fixing the metadata.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我将根据我们今天所知道的情况回答我自己的问题。
我们本质上已经陷入了一些不受欢迎的功能的恶性相互作用中。
1) 根据在这篇文章中,IE9 会忽略 iframe 内页面的 doctype,并始终使用父页面的 doctype。
我希望有人能够证实或否认这一信息,一篇论坛帖子没什么可说的,但它与我们所看到的相符。
2) MS Outlook Web 应用程序 2011 版(版本:14.1.287.0)与 Internet Explorer 9 不兼容。要显示这一点,请尝试以下操作:找到正在运行的 Outlook Web 应用程序,例如http://mail.mycompany.com 使用 IE9 连接到它。登录。按 F12 打开开发人员工具。请注意,右上角有“文档模式:IE7 标准”。 IE9 正在模拟 IE7 来运行该网站。
您可以更改此模式:单击它并选择“文档模式:IE9 标准”。请注意,“控制台”选项卡现在显示上面提到的有关缺少
__defineGetter__
方法的错误,并且 Web 应用程序的某些部分无法工作 - 单击列表中的消息或单击回复按钮现在不会执行任何操作。感谢 Outlook 团队不使用标准,也不针对您自己的浏览器的当前版本。
3)
__defineGetter__
方法在 IE9 中不起作用。它已被弃用,应使用defineProperty
代替。这很公平,但__defineGetter__
仍然存在于当前版本的 Firefox 和 Chrome 中,因此 Outlook 可以正常工作。在 IE9 中它不存在,除非 IE9 假装是旧版本的 IE。I'll answer my own question, based on what we know today.
We essentially have been caught in the malign interaction of a few unwelcome features.
1) As per this post, IE9 ignores the doctype of pages inside iframes, and always uses the parent page's doctype instead.
I hope someone can confirm or deny this information, one forum post isn't much to go on, but it fits with what we have seen.
2) The MS Outlook web app, the 2011 version (Version: 14.1.287.0), is not compatible with Internet Explorer 9. To show this, try the following: find a running Outlook web app, e.g. http://mail.mycompany.com connect to it with IE9. Log in. Press F12 to bring up the developer tools. Note that at the top right you have "Document Mode: IE7 standards". IE9 is emulating IE7 in order to run the site.
You can change this mode: click it and select "Document Mode: IE9 standards". Note that the Console tab now shows an error mentioned above about the missing
__defineGetter__
method and that parts of the web app don't work - clicking on messages in the list or clicking on the reply button does nothing now.Thanks, Outlook team for not using standards and for not targeting the current version of your own browser.
3) The
__defineGetter__
method does not work in IE9. It is deprecated, anddefineProperty
should be used instead. That is fair enough, but__defineGetter__
is still present in current versions of Firefox and Chrome, and so Outlook works. In IE9 it is absent unless IE9 is pretending to be an older version of IE.您只需将此元数据放入您的页面/母版页中即可:
Xam666
You just have to put this meta in your page/masterpage :
Xam666
查看这些。元标记可以帮助
http://blogs.msdn.com/b/askie/archive/2009/03/23/understanding-compatibility-modes-in-internet-explorer-8.aspx
文档是对于 IE8。也应该给出 IE9 的指针。
网页可以通过使用 Meta 标记或发送 http 标头来指定兼容模式。当两者都存在时,元标记优先于 http 标头。
1) META 标签 - 您可以将以下 HTML 标签放置在网页的 HEAD 元素中:
2) HTTP 标头 - 您可以配置服务器,以便与每个页面一起发送以下 HTTP 标头
X-UA-兼容:IE=7
Review these. Meta tags can help
http://blogs.msdn.com/b/askie/archive/2009/03/23/understanding-compatibility-modes-in-internet-explorer-8.aspx
The docs are for IE8. should give pointers for IE9 as well.
Webpage can specify compatibility mode either by using a Meta tag or by sending a http header. Meta tag takes precedence over http header when both are present.
1) META Tag - You can place the following HTML tag in the HEAD element of your web page:
2) HTTP Header - You can configure your server so that the following HTTP Header is sent with each page
X-UA-Compatible: IE=7