Permalink
Browse files

Added link to README; updated Fullscreen to include new Webkit syntax…

… and IE11 support
  • Loading branch information...
1 parent 7d33b7d commit 24f6b3f2382eae298e263e9ece96ea8c3b32252b @stopsatgreen committed Jul 5, 2013
Showing with 41 additions and 8 deletions.
  1. +40 −7 Code Examples/Chapter 06/fullscreen.html
  2. +1 −1 README.md
@@ -16,14 +16,17 @@
var trigger = document.getElementById('trigger'),
target = document.getElementById('target');
trigger.addEventListener('click', function () {
- if (target.requestFullscreen) {
- target.requestFullscreen();
- } else if (target.mozRequestFullScreen) {
- target.mozRequestFullScreen();
- } else if (target.webkitRequestFullscreen) {
- target.webkitRequestFullscreen();
- }
+ var canFull = target.goFullscreen = (
+ target.requestFullscreen ||
+ target.mozRequestFullScreen ||
+ target.webkitRequestFullscreen ||
+ target.msRequestFullscreen
+ )
+ if (canFull) {
+ target.goFullscreen();
+ };
}, false);
+ // Firefox
document.addEventListener('mozfullscreenchange', function () {
if (document.mozFullScreenElement !== null) {
document.addEventListener('keydown', function (e) {
@@ -33,6 +36,36 @@
}, false);
}
}, false);
+ // Safari (desktop) and Chrome
+ document.addEventListener('webkitfullscreenchange', function (e) {
+ if (document.webkitFullscreenElement !== null) {
+ document.addEventListener('keydown', function (e) {
+ if (e.keyCode === 13) {
+ document.webkitExitFullscreen();
+ }
+ });
+ }
+ });
+ // Safari (iOS)
+ document.addEventListener('webkitbeginfullscreen', function (e) {
+ if (document.webkitFullscreenElement !== null) {
+ document.addEventListener('keydown', function (e) {
+ if (e.keyCode === 13) {
+ document.webkitExitFullscreen();
+ }
+ });
+ }
+ });
+ // IE11+
+ document.addEventListener('MSFullscreenChange', function (e) {
+ if (document.msFullscreenElement !== null) {
+ document.addEventListener('keydown', function (e) {
+ if (e.keyCode === 13) {
+ document.msExitFullscreen();
+ }
+ });
+ }
+ });
},false);
</script>
</body>
View
@@ -1,6 +1,6 @@
modernwebbook
=============
-These are the code examples from my book, The Modern Web. They'll be kept updated as the technology progresses. Please feel free to fork and modify as you see fit.
+These are the code examples from my book, [The Modern Web](http://modernwebbook/). They'll be kept updated as the technology progresses. Please feel free to fork and modify as you see fit.
Note that the exact markup and style of some demos may differ from the examples in the book, but the underlying concepts remain unchanged.

0 comments on commit 24f6b3f

Please sign in to comment.