Skip to content

Commit

Permalink
Add visibility change demo
Browse files Browse the repository at this point in the history
  • Loading branch information
beaufortfrancois committed Jun 10, 2018
1 parent 38661c2 commit 0c94eea
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions visibility-change.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<html><body>
<script>
document.addEventListener('visibilitychange', onVisibilityChange);

function onVisibilityChange() {
if (document.hidden) {
document.body.style.backgroundColor = 'red';
} else {
document.body.style.backgroundColor = 'green';
}
}

onVisibilityChange();
</script>
</html></body>

0 comments on commit 0c94eea

Please sign in to comment.