JS说没有定义表单(FireFox 4.0)

时间:2011-04-29 08:22:38

标签: javascript html

这是我的代码

<form name='logOut' id="logOut" action="/ProCommerce/index.php" method="post">
        <input name="logMeOut" type="hidden" value="1">
    </form>
    <script type="text/javascript">
        $(document).bind('keydown', 'Ctrl+shift+l', function(){
            showDiv('loginDiv');
        });
        $(document).bind('keydown', 'Ctrl+shift+o', function(){
            logOut.submit();
        });
    </script>

它在Chrome和IE中运行良好,但在FireFox中我总是得到:错误:未定义logOut 源文件:http://localhost/ProCommerce/index.php?action=home 行:416

我该怎么办?

2 个答案:

答案 0 :(得分:0)

我原本期望$(“#logOut”)。submit();

答案 1 :(得分:0)

直接从全局窗口对象访问DOM元素只在IE中支持,所以在firefox中你可能会document.getElementById('logOut').submit()$('#logOut').submit()