Possible Duplicate:
Javascript: Is there any way to detect that window is currently active? (i.e. is beening shown on active tab/window)
I have a web-based dashboard which displays critical time-sensitive messages to nurses etc. on a hospital floor. The challenge is that if the dashboard is not open or is minimized, they will not see the message and be able to respond. I currently track percent of time that the app is running (it polls for new messages over AJAX every 10 seconds so I can easily see how many requests it does per hour or whatever), but that doesn't tell me whether the app was minimized.
One method would be to use onfocus
/onblur
, but that has limited effectiveness since most of the computers where this is deployed are dual-monitor machines and they often will keep the dashboard open on one screen while using the Clinical Information System on the other screen. This state will count as "unfocused" with the focus/blur method, but I want it to count as "open" for my stats.
Any ideas for detecting window visibility? I'm thinking maybe include a tiny Flash "pixel" and detect whether that is visible - any other ideas?