javascript - 在窗口对象上附加鼠标事件在 Internet Explorer 8 中不起作用

标签 javascript internet-explorer events

天哪,谁知道为什么 Internet Explorer (8) 不触发附加到窗口的事件?

    attachEvent("onmousedown", function(){alert("here")}); //Doesn't work.
    onmouseup = function(){alert("here 2")}; //Guess what? Doesn't work too.

当然,我什至不用说这适用于 Firefox、Opera 和 Chrome

    addEventListener("mousedown", function(){alert("here")}, false)
    onmouseup = function(){alert("here 2")};

attachEvent 在 div 上工作或*在此处插入任何 DOM 元素*,但我需要该事件是全局的。

最佳答案

尝试将其附加到文档中

关于javascript - 在窗口对象上附加鼠标事件在 Internet Explorer 8 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5336949/

相关文章:

javascript - jQuery改变图像不透明度onclick

javascript - Angular 中 .success() 或 .then() 哪个更好

c# - 设置 WebBrowser 控件兼容模式不起作用

javascript - Vue 中的 RxJS 入门

javascript - 使用 jQuery 和 CSS 设计一个 d3 元素

c# - 是否可以在 IE 中使用 "autopopulate"字段?

html - CSS 不适用于 IE 和 Firefox,但适用于 Chrome

div 刷新时的 Jquery 事件

Android ListView如何获取空 View 事件

c++ - Qt多键组合事件