Page Visibility API - Have I got your attention?
bookmark_borderbookmark
Stay organized with collections
Save and categorize content based on your preferences.
Multi-tab browsing is now the norm, so you can't assume the user is watching your app just because it's running. Fortunately, the new Page Visibility API lets your app discover if it's visible or not. You could use the API to cut down on unnecessary network activity and computation.
document.webkitHidden
is a boolean value indicating if the current page is hidden (you can try it now in the console if you're using a recent build of Chromium). document.webkitVisibilityState
will return a string indicating the current state, one of visible
, hidden
, and prerendered
. And a new webkitvisibilitychange
event will fire when any of these changes, e.g. when the user opens you app's tab, or moves away from it.
If you're interested in giving this a whirl, check out visibility.js which adds a little bit of sugar on the API to make watching these interactions a bit more fun.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2011-06-27 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2011-06-27 UTC."],[],[]]