document.onclick vs window.onclick [英] document.onclick vs window.onclick
问题描述
document.onclick
和
window.onclick
事件?
谢谢。
推荐答案
JavaScript Window对象是与Web浏览器窗口对应的最高级JavaScript对象。
The JavaScript Window object is the highest level JavaScript object which corresponds to the web browser window.
文档对象是HTML文档的HTML标记内关联的所有HTML HEAD和BODY对象的容器。这可能对应于最顶层窗口或窗口内的iframe。
The document object is the container for all HTML HEAD and BODY objects associated within the HTML tags of an HTML document. This could correspond to the top-most window, or an iframe within the window.
更新
快速测试后两者之间确实没有区别。但是,正如其他人所说,在IE8中测试时,window.onclick不起作用。显然,底线是 document.onclick
是首选。
After a quick test there really is no difference between the two. However, as others have said, window.onclick did not work when tested in IE8. So apparently the bottom line is that document.onclick
is the preferred choice.
这篇关于document.onclick vs window.onclick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!