5

好的,所以我有这段代码,但这是一个简化版本:

<!DOCTYPE html>
<html>
    <head>
        <title>_</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <script>

            Object.defineProperty(
                Array.prototype,'len',{get:
                    function(){return this.length}
            });

            function pop(){
                ary=['abc',123];
                d1.innerText=ary.len;
            }

        </script>
    </head>
    <body onload="pop()">
        <div id="d1">d1</div>
    </body>
</html>

所以我的设置是:

  1. v40.0.2214.94 米
  2. IE v11.0.9600.16428
  3. IIS v7.5.7600.16385

当我打开任一浏览器并打开上述文件时:

IE ==> C:\site\proj\default.htm
Chrome ==> file:///C:/site/proj/default.htm

两种浏览器都显示正确的结果:2......但是当我这样打开文件时:

IE ==> http://门户/proj/default.htm
Chrome ==> http://门户/proj/default.htm

其中portallocalhost站点的名称,在IIS中设置。

IE显示undefined并引发以下控制台错误:

对象不支持属性或方法“defineProperty”

虽然Chrome仍能2正确显示。


所以,我想我的问题是......

IIS是否会更改IE的“兼容模式”之类的,还是我只需要更新到更新版本的IIS


思考是...

我第一次玩.hta文件&我正在编写一个Array.prototype.indexOf属性,因为我在尝试访问.indexOf数组时收到与上面类似的错误消息......

问题是,我想让新indexOf属性enumerable,所以我曾经Object.defineProperty将属性设置为enumerable,这就是我最终在 Stack'...

4

1 回答 1

0

我认为问题出在 IIS 中,我在 IE11/Win7/NodeJs 服务器中测试了该页面,我可以看到“2”。

于 2015-02-24T10:04:22.633 回答