/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] window.blur

i have this piece of code:

[CODE]
window.addEventListener( “focus” , function()
{
window.console.log(“focus”);
} , false );

window.addEventListener( “blur” , function()
{
window.console.log(“blur”);
} , false );
[/CODE]

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 😕 …

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@acestuffJun 18.2011 — I can imagine that the problem is you can't go blurring the user's browser whenever you want. Imagine if you had this on a website:
[CODE]
window.addEventListener(
"focus",
function() {
window.blur();
}
);
[/CODE]

would it mean that I could never get focus to my own browser?

Also, not all browsers support blur on the window element (IMO blur shouldn't be allowed on the window element - the only people who are going to find it useful are those making popups!)

In summary: I'd guess it doesn't work not because you're doing it wrong rather the browser doesn't like what you're doing.

Source:

http://www.w3schools.com/jsref/met_win_blur.asp
Copy linkTweet thisAlerts:
@Revolt666authorJun 18.2011 — I can imagine that the problem is you can't go blurring the user's browser whenever you want. Imagine if you had this on a website:
[CODE]
window.addEventListener(
"focus",
function() {
window.blur();
}
);
[/CODE]

would it mean that I could never get focus to my own browser?

Also, not all browsers support blur on the window element (IMO blur shouldn't be allowed on the window element - the only people who are going to find it useful are those making popups!)

In summary: I'd guess it doesn't work not because you're doing it wrong rather the browser doesn't like what you're doing.

Source:

http://www.w3schools.com/jsref/met_win_blur.asp[/QUOTE]


i never thought at this problem. i guess your right. thanks
×

Success!

Help @Revolt666 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...