visibilitychange
Summary
Set the visibility state of an element
Property of dom/Documentdom/Document
Syntax
var result = element.visibilitychange;
element.visibilitychange = value;
Examples
var timer = 0;
var PERIOD_VISIBLE = 1000;
var PERIOD_NOT_VISIBLE = 60000;
function onLoad() {
timer = setInterval(checkEmail, (document.hidden) ? PERIOD_NOT_VISIBLE : PERIOD_VISIBLE);
if(document.addEventListener) document.addEventListener("visibilitychange", visibilityChanged);
}
function visibilityChanged() {
clearTimeout(timer);
timer = setInterval(checkEmail, (document.hidden) ? PERIOD_NOT_VISIBLE : PERIOD_VISIBLE);
}
function checkEmail() {
// Check server for new messages
}
window.onload = onLoad;
Notes
Remarks
This event is not triggered when it is registered.
Syntax
Event handler parameters
This method has no parameters.
Related specifications
- Page Visibility
- Recommendation
See also
Related articles
Performance
visibilitychange
Attributions
Microsoft Developer Network: [Windows Internet Explorer API reference Article]