Link to home
Start Free TrialLog in
Avatar of iamnatio
iamnatio

asked on

How to check if popup window is focused in JavaScript?

Hello,

If we have a popup window open and it is not in focus how can we check it? If the popup is not in focus and the user is looking at something else I want to play a "beep" sound using <embed>. However if they are focused on the popup I do not wan to play this "beep" sound.

To explain in further detail I have a Instant Messenger running and if the user does not have the IM focused and they get a new message there is no way in letting them know. So I thought a "beep" sound would be nice. I found a way to simply focus() the window, however don't think many will like that.

Any help would be appreciated.

Thank you
ASKER CERTIFIED SOLUTION
Avatar of Bob Butcher
Bob Butcher
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I know I've written web apps to play sounds if certain conditions appear with:

<bgsound src='mysound.wav' loop='3' />

and it works great.
Avatar of iamnatio
iamnatio

ASKER

Thank you very much, just what I was looking for.