Permalink
Browse files

add test

  • Loading branch information...
1 parent e50225a commit b904030f7e0d507cfae65010527aa71a16252310 @ianb committed Jul 26, 2012
Showing with 41 additions and 0 deletions.
  1. +41 −0 visibilitytest.html
View
41 visibilitytest.html
@@ -0,0 +1,41 @@
+<html>
+ <head>
+ <title>Visibility test</title>
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
+ <script>
+ // Browser compatibility:
+ var hidden, visibilityChange;
+ if (typeof document.hidden !== "undefined") {
+ hidden = "hidden";
+ visibilityChange = "visibilitychange";
+ visibilityState = "visibilityState";
+ } else if (typeof document.mozHidden !== "undefined") {
+ hidden = "mozHidden";
+ visibilityChange = "mozvisibilitychange";
+ visibilityState = "mozVisibilityState";
+ } else if (typeof document.msHidden !== "undefined") {
+ hidden = "msHidden";
+ visibilityChange = "msvisibilitychange";
+ visibilityState = "msVisibilityState";
+ } else if (typeof document.webkitHidden !== "undefined") {
+ hidden = "webkitHidden";
+ visibilityChange = "webkitvisibilitychange";
+ visibilityState = "webkitVisibilityState";
+ }
+
+ document.addEventListener(visibilityChange, function () {
+ var isHidden = document[hidden];
+ var state = document[visibilityState];
+ var text = $('#output').text();
+ text += '\n';
+ text += visibilityChange + ' hidden: ' + isHidden + ' state: ' + state + ' at ' + (new Date());
+ $('#output').text(text);
+ }, false);
+ </script>
+ </head>
+ <body>
+
+ <pre id="output"></pre>
+
+ </body>
+</html>

0 comments on commit b904030

Please sign in to comment.