简体   繁体   English

IE9中iframe中的Javascript版本

[英]Javascript version inside iframe in IE9

I have a web application that puts the outlook web app inside an iframe. 我有一个将Outlook Web App放在iframe中的Web应用程序。 This works quite well in most browsers, but it fails in IE9, with an error in outlook's javascript: 这在大多数浏览器中都可以很好地运行,但是在IE9中失败,并且Outlook的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. 尽管大多数其他浏览器都支持__defineGetter__函数,但IE9中不存在__defineGetter__函数,这似乎正在发生。 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. 邮件应用程序通常以IE7标准模式运行-如果我自己打开Web邮件并按F12(开发工具),则会看到Browser Mode: IE9, Document Mode: IE7 standards ,并且没有问题。

However when I run the app that has outlook mail in an iframe, I see Browser Mode: IE9, Document Mode: IE9 standards . 但是,当我运行在iframe中具有Outlook邮件的应用程序时,会看到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. 这适用于外部站点,没有明显的方法可以找到iframe在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. 看起来iframe中的JavaScript正在运行,就好像它不是版本一样。 Of course it's still isolated so I can't monkeypatch this function in as per this hack . 当然,它仍然是孤立的,因此我无法按照此hack对该功能进行修补。

How can I force the iframe contents to run JavaScript in IE7 mode, differently from the rest of the website? 与网站的其他部分不同,如何强制iframe内容以IE7模式运行JavaScript? We don't want to edit the code inside the iframe? 我们不想在iframe中编辑代码吗? We don't want to do that since it's just stock outlook web app. 我们不想这样做,因为它只是股票前景Web应用程序。 And if we do have to go there, we would just go for fixing their JavaScript not fixing the metadata. 而且,如果我们必须去那里,我们将只修复其JavaScript,而不修复元数据。

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. 1)根据这篇文章 ,IE9会忽略iframe中页面的文档类型,而始终使用父页面的文档类型。

IE9 forces the child page to the same DOCTYPE as the parent page. IE9强制将子页面设置为与父页面相同的DOCTYPE。 No matter what. 无论。 ... Microsoft's response is that it's working as designed. 微软的回应是它正在按设计工作。

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, eg http://mail.mycompany.com connect to it with IE9. 2) MS Outlook Web应用程序2011版(版本:14.1.287.0)与Internet Explorer 9不兼容。要显示此信息,请尝试以下操作:查找正在运行的Outlook Web应用程序,例如http://mail.mycompany .com使用IE9连接到它。 Log in. Press F12 to bring up the developer tools. 登录。按F12调出开发人员工具。 Note that at the top right you have "Document Mode: IE7 standards". 请注意,在右上角有“文档模式:IE7标准”。 IE9 is emulating IE7 in order to run the site. IE9正在模拟IE7,以便运行该站点。

You can change this mode: click it and select "Document Mode: IE9 standards". 您可以更改此模式:单击它,然后选择“文档模式:IE9标准”。 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. 请注意,“控制台”选项卡现在显示上面提到的有关缺少的__defineGetter__方法的错误,并且Web应用程序的某些部分不起作用-单击列表中的消息或单击“答复”按钮现在不起作用。

Thanks, Outlook team for not using standards and for not targeting the current version of your own browser. 感谢Outlook团队不使用标准,也没有针对您自己的浏览器的当前版本。

3) The __defineGetter__ method does not work in IE9. 3) __defineGetter__方法在IE9中不起作用。 It is deprecated, and defineProperty should be used instead. 不建议使用它,而应改用defineProperty That is fair enough, but __defineGetter__ is still present in current versions of Firefox and Chrome, and so Outlook works. 这足够公平,但是__defineGetter__仍存在于当前版本的Firefox和Chrome中,因此Outlook可以使用。 In IE9 it is absent unless IE9 is pretending to be an older version of IE. 在IE9中,除非IE9假装为IE的旧版本,否则它是不存在的。

You just have to put this meta in your page/masterpage : 您只需要将此meta放在您的页面/母版页中:

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

Xam666 Xam666

Review these. 查看这些。 Meta tags can help 元标记可以提供帮助

http://blogs.msdn.com/b/askie/archive/2009/03/23/understanding-compatibility-modes-in-internet-explorer-8.aspx http://blogs.msdn.com/b/askie/archive/2009/03/23/understanding-compatibility-modes-in-internet-explorer-8.aspx

The docs are for IE8. 该文档适用于IE8。 should give pointers for IE9 as well. 还应提供IE9的指针。

Webpage can specify compatibility mode either by using a Meta tag or by sending a http header. 网页可以使用Meta标签或发送http标头来指定兼容模式。 Meta tag takes precedence over http header when both are present. 如果同时存在meta标头,则它们优先于http标头。

1) META Tag - You can place the following HTML tag in the HEAD element of your web page: 1)META标记-您可以在网页的HEAD元素中放置以下HTML标记:

2) HTTP Header - You can configure your server so that the following HTTP Header is sent with each page 2)HTTP标头-您可以配置服务器,以便随每个页面发送以下HTTP标头

X-UA-Compatible: IE=7 兼容X-UA:IE = 7

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM