IE上的iframe中的JavaScript

时间:2016-12-22 20:47:05

标签: javascript internet-explorer knockout.js

我在IE上的iframe中运行JavaScript时遇到问题(需要在IE9,quirks模式下工作)。

来了

["click", "mousemove", "keypress"].forEach(function(name){}

抛出错误

  

Object不支持属性或方法'forEach'

Knockout.js也无效

  

'ko'未定义

代码基于Rainloop webmail应用程序。它的标题(iframe)看起来像:

<!DOCTYPE html>
<html class="no-js rl-booted-trigger rl-started-trigger">
    <head>
        <meta charset="utf-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <meta id="rl-head-viewport" name="viewport" content="width=950,maximum-scale=2">
        <meta name="apple-mobile-web-app-capable" content="yes" />
    <script type="text/javascript"> if (!window.console) console = {log: function() {}}; </script>
    <noscript>
        <meta http-equiv="refresh" content="0; URL=./?/NoScript" />
    </noscript>
    <!--[if lte IE 8]>
        <meta http-equiv="refresh" content="0; URL=./?/BadBrowser" /> 
    <![endif]-->
    <script data-cfasync="false">
        if (!window.navigator || !window.navigator.cookieEnabled) {
            window.document.location.replace('./?/NoCookie');
        }
    </script>
    <meta name="Author" content="RainLoop Team" />
    <meta name="robots" content="noindex, nofollow, noodp" />
    <meta name="google" content="notranslate" />
[... rest is from the Rianloop JS code...]

有任何线索如何让它发挥作用?

1 个答案:

答案 0 :(得分:0)

基于Teemu建议解决方案是将父窗口模式从Quirks更改为标准,因为forEach未在Quirks中实现,因此Konckout.js无法在该模式下工作。