Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rushi/jquery.visibility.js
Cross-browser jQuery plugin to react on visibility change
https://github.com/rushi/jquery.visibility.js
Last synced: about 2 months ago
JSON representation
Cross-browser jQuery plugin to react on visibility change
- Host: GitHub
- URL: https://github.com/rushi/jquery.visibility.js
- Owner: rushi
- Created: 2013-07-14T06:58:13.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-07-14T06:59:03.000Z (over 11 years ago)
- Last Synced: 2023-07-01T08:20:34.871Z (over 1 year ago)
- Size: 102 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# jQuery Visibility Change Event
This cross-browser jQuery plugin allows you to execute a particular callback when the browser's visibility event changes. This event usually occurs when you switch to another tab.
# Examples
$(window).visibilityChange(function(event) {
// This will be executed when you switch to another tab
console.log("Goodbye World. I fired on" + event.name)
});Pass in some arguments:
var a = 1, b = 2;
$(window).visibilityChange(function(event) {
// This will be executed when you switch to another tab
console.log("Goodbye World. Here are some arguments", arguments)
}, a, b);# Use Cases
What could you use the Visibility API for?
* Track the time users actually spend on your website. This number maybe significantly lower than your analytics package reports
* A site has an image carousel that shouldn't advance to the next slide unless the user is viewing the page.
* An application showing a dashboard of information doesn't want to poll the server for updates when the page isn't visible.
* A page wants to detect when it is being prerendered so it can keep accurate count of page views.Check out [Mozilla's Documentation](https://developer.mozilla.org/en-US/docs/Web/Guide/User_experience/Using_the_Page_Visibility_API) or the [Google Developer's API](https://developers.google.com/chrome/whitepapers/pagevisibility) for more detailed information.
# Testing
## Browsers
Google Chrome v28 and Firefox 22 are tested but Internet Explorer is not.
## jQuery
Tested on jQuery > 1.7