在IE 8和IE7中,document.onmouseover和onmouseout事件参数未定义

时间:2013-03-08 15:17:39

标签: javascript internet-explorer internet-explorer-8

参数e是Chrome,FF和IE 9中的正确事件,但在IE 8和IE 7中是“未定义的”。在IE 9中使用F12 devtools可重现浏览器模式:IE 8和文档模式:IE 8也。

注意:该函数被正确调用我的“唯一”问题,即e未定义...

<script>
    document.onmouseover = function(e) {
    // parameter e is the correct event in Chrome, FF and IE 9
    // but 'undefined' in IE 8 and IE 7. Reproducable in IE 9 using F12 devtools
    // Browser Mode: IE 8 and Document Mode: IE 8 also.
    // NOTE: The function is called properly my 'only' problem that e is undefined

    ... work with parameter e here
}
</script>

有什么想法吗? 提前你

1 个答案:

答案 0 :(得分:2)

IE以不同的方式执行事件,因此它无效。

document.onmouseover = function(e) {
  e = e || window.event;
}