Window focus() 方法
- Previous Page document
- Next Page frameElement
- Go to the Previous Level Window Object
定义和用法
focus()
方法向窗口设置焦点。
blur()
方法从窗口移除焦点。
注意
focus()
方法发出将窗口置于最前面的请求。
由于用户设置不同,它可能无法按预期工作。
另请参阅:
实例
例子 1
打开新窗口并设置焦点:
const myWindow = window.open("", "", "width=200, height=100"); myWindow.focus();
例子 2
打开新窗口并模糊焦点:
const myWindow = window.open("", "", "width=200, height=100"); myWindow.blur();
Syntax
window.focus()
Parameter
None.
Return Value
None.
Browser Support
All Browsers Support focus()
:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support | Support |
- Previous Page document
- Next Page frameElement
- Go to the Previous Level Window Object