为什么这个javascript代码没有在FireFox中运行

时间:2010-03-25 16:49:49

标签: javascript firefox

   <script type="text/javascript">

 if (window.name == 'default') {
        window.name = 'a03d01c6c88549c6a7e05c922961271e';
        window.document.getElementById('ctl03').click();
    }
    else if (window.name == '') {
        window.name = 'default';
        window.document.getElementById('ctl04').click();
     }
    else if (window.name == 'invalidAccess') {
        if ('FALSE' == 'TRUE')
        {
         window.name='';
        window.document.getElementById('ctl04').click();
        }
        else
        {
            window.open('MsgPage_NewWindow.aspx','_self');
        }
    }
    else {
        window.name = 'invalidAccess';
        window.document.getElementById('ctl04').click();
    }
</script>

上面的脚本是由服务器控件在页面上发出的,是一个WebPage ...除页面外,页面中没有其他控件... Internet Explorer将其重定向到页面“Home.aspx”,但是Firefox只是停留在同一页面...注意它显示任何错误。

你能帮忙吗?我也想知道原因,因为我必须使整个Web应用程序在FF中运行。

2 个答案:

答案 0 :(得分:4)

您正在使用专有的IE click方法重定向。

你应该写location.href = "http://url";代替;这将适用于每个浏览器。

答案 1 :(得分:1)

您是否正在使用工具 - >错误控制台?如果你这样做,你会看到“点击不是一个功能”之类的东西,试着简单地设置.location。