--- title: Window.focus() slug: Web/API/Window/focus tags: - API translation_of: Web/API/Window/focus ---
{{APIRef}}
请求将窗口显示在前(靠近屏幕),这可能由于用户设置而失败,并且该窗口在方法返回之前不能保证会显示在最前.
window.focus()
if (clicked) { window.focus(); }
Specification | Status | Comment |
---|---|---|
{{SpecName('HTML WHATWG','interaction.html#dom-window-focus','Window.focus()')}} | {{Spec2('HTML WHATWG')}} |
{{ languages( { "ja": "ja/DOM/window.focus", "pl": "pl/DOM/window.focus" } ) }}