简体   繁体   中英

Javascript window.blur()

I have this piece of code:

window.addEventListener( "focus" , function(){
    window.console.log("focus");
} , false );

window.addEventListener( "blur" , function(){
    window.console.log("blur");
} , false );

And if I run : setTimeout("window.focus();",2000); from firebug's console I get "focus" after 2 seconds but if I run setTimeout("window.blur();",2000); I don't get "blur".

Could someone help me please? I don't understand it, it should work.

I'm not quite sure, but try this:

setTimeout(function() {
    window.blur();
}, 2000);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM