/    Sign up×
Community /Pin to ProfileBookmark

onmouseover="window.focus" after user has given focus to outside window (doable?)

Hello all,

I am trying to steal back Windows’s “focus” without requiring the user to “click” somewhere inside the web browser window.

Let me explain :

When you are on my website, if you hover any of my scrollable areas you can use your mousewheel to scroll up and down. I like this. If for any reason you go to another window (say Word or Outlook, a window that isn’t the web browser window) and you click in there.. then obviously the focus has switched. If you then hover back to my window (because you have dual monitors and both windows were fully visible at the same time) well you can’t scroll with your mousewheel anymore (doing so will actually scroll in Word or Outlook). You have to first click inside of the browser window.

Right…

Oddly though.. the mouseover events still register even though you haven’t clicked inside the new window.. quite odd this.

I tried adding a onmouseover=’window.focus()’ on an element that spans the entire viewable area of my website. This event is indeed registered (tested with an alert) yet it doesn’t solve my problem of the user still having to CLICK inside the browser window before he can hover scrollable areas and scroll them with his mousewheel.

Any ideas why? or how I might solve this issue?

Thanks for any insight!

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisAug 04.2008 — There is a difference between the window content and the browser itself. The O/S probably controls the scrolling with the mouse wheel. However, the window content will still react with onmouseover/out. Apparently, the O/S won't allow window content to steal the focus that the user has established. Probably a security measure.
Copy linkTweet thisAlerts:
@felgallAug 04.2008 — focus is not a standard event for windows and so only some browsers support setting window.focus at all.
×

Success!

Help @vesper8 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.7,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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