转自一个邮件列表。
this.window.focus()
When used in-line in the body tag, 'this' refers to the body element.
In a standard DOM, the body element doesn't have a window property;
trying to call a method of a non-existent property will result in a
script error.
window.focus()
This calls the focus method of the window object, which should work in
standards-compliant browsers though it may not have any effect. Some
browsers provide user configurable settings so that users can prevent
script from raising or lowering windows.
this.focus()
This will attempt to call the focus method of the body element. The
W3C DOM 2 HTMLBodyElement interface doesn't define a focus method,
therefore it's likely to fail in most (if not all) browsers.
本文探讨了JavaScript中window.focus()、this.focus()等方法的使用及其在不同浏览器中的表现。解释了'window.focus()'如何使窗口获得焦点,以及'body'元素尝试调用'focus()'方法时可能遇到的问题。

1万+

被折叠的 条评论
为什么被折叠?



