/    Sign up×
Community /Pin to ProfileBookmark

onmouseOut does not fire after returning from ALT+TAB

I made a DTHML menu using CSS and Javascript. Here is something I noticed that I didn’t find anything about searching the forums.

I mouseover the menu and the submenu appears and I move my mouse onto the submenu. Then I ALT+TAB to any other app or window and move the mouse to a position such that when I ALT+TAB back to the window containing the menu the mouse will no longer be anywhere inside of the object that fired the mouseover event.

When I do this, the mouseout event attached to the submenu never fires and the submenu remains visible.

Any ideas?

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@mrhooApr 12.2007 — alt-tab moves the focus, not the mouse. Use focus and blur for key events

simulating mouseover and mouseout.
Copy linkTweet thisAlerts:
@konithomimoApr 13.2007 — The onmouseout function can only fire when the mouse moves away from the object while the window is being actively used. When you alt+tab away and then come back the window will not have registed the onmouseout, since it did not happen while the window was active. The onmouseout will not fire until the next time you mouseover and then mouseout of that object. Even using onblur wont fix this problem. Instead you will have to check and see if the mouse is not over the menu when it moves, and if not then hide the menu. Most likely you would do this from the body element.
Copy linkTweet thisAlerts:
@spiehauthorApr 13.2007 — Is there someway to set a timeout to hide the menu and cancel the timeout when you are currently on the menu?
Copy linkTweet thisAlerts:
@spiehauthorApr 15.2007 — I did this.

[CODE]window.onblur = hideall;

function hideall ()
{
divArray = document.getElementsByTagName('div');
for (var i = 0;i<divArray.length;i++)
{
if(divArray[i].className == "visibleMenu")
{
divArray[i].className == "hiddenMenu";
}
}
}[/CODE]


This will hide every menu in my page if the window loses focus. However it seems like it could be resource intensive checking every div every time the window loses focus. It works but maybe not the best way of doing it.
Copy linkTweet thisAlerts:
@ricpApr 15.2007 — The question really is, why would the user alt+tab while a menu is open. It's pretty unlikely unless the user had an immediate need to swap processes. In that case I think it's completely acceptable to leave the menus "open" when the window blurs.

btw, if you were to use something like the suckerfish menu (which relies on CSS and not JS) then the problem you have wouldn't arise.

http://alistapart.com/articles/dropdowns
Copy linkTweet thisAlerts:
@spiehauthorApr 16.2007 — When an anchor link gains focus window.onblur executes and hides all the menus. This doesn't really matter if the link goes somewhere but if I have href="#" then I would like the menu to remain visible if the clicked link doesn't go anywhere. This only happens once in IE but it fires window.onblur multiple times in firefox when the links gain focus.

Guess I'll have to come up with some other way to fix the issue.

BTW, I know its unlikely for an average user to alt-tab while moving over a menu. The place this is being deployed uses a soft phone system that has a small pop-up that steals focus when a call comes into the phone. So the user may not alt-tab but this issue is for when the window loses focus for any reason while the menu is active.
×

Success!

Help @spieh 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.15,
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,
)...