O'Reilly logo

Mastering jQuery by Alex Libby

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Detecting support for the Page Visibility API

Although the API will work perfectly well in most modern browsers, it will fail in a limited number; IE8 is a good example. To get around this, we need to provide either a root to gracefully degrade, or use a fallback; step one to this process is to first work out if our browser supports the API.

There are different ways to do this. We could use the Modernizr.addTest option from Modernizr (from http://www.modernizr.com). Instead, we're going to use a plugin by Matthias Bynens, which contains a check for support for older browsers. The original version is available from https://github.com/mathiasbynens/jquery-visibility. The version included in the code download is a cut-down copy, which removes support ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required