为什么 IE 核对 window.ABC 变量? [英] Why does IE nuke window.ABC variables?

查看:18
本文介绍了为什么 IE 核对 window.ABC 变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当运行以下代码块时,FF 和 Chrome 输出 typeof(hiya) = string 而 IE7/8 输出 typeof(hiya) = undefined.

When running the following block of code, FF and Chrome output typeof(hiya) = string while IE7/8 output typeof(hiya) = undefined.

<html>
    <body>
        <script type="text/javascript">
            window.hiya = 'hiya';
        </script>
        <script type="text/javascript">
            if( false ) {
                var hiya = 1;
            }
            document.write( "typeof(hiya) = "+ typeof(hiya) );
        </script>
    </body>
</html>

以下每一项都会使问题消失:

Each of the following makes the problem go away:

  • 将所有内容组合成一个
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆