开发者

Javascript version inside iframe in IE9

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.


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.

IE9 forces the child page to the same DOCTYPE as the parent page. 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, 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, and defineProperty 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.


You just have to put this meta in your page/masterpage :

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

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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜