Skip to content

Commit 22b1d94

Browse files
author
Klaus Reimer
committed
Added support for Internet Explorer 11.
Thanks to Ales Hladilek for the contribution.
1 parent 5ca8515 commit 22b1d94

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

jquery.fullscreen-min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jquery.fullscreen.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,31 @@ function fullScreen(state)
5353
// When fullscreen mode is not supported then return null
5454
if (!((/** @type {?Function} */ doc["cancelFullScreen"])
5555
|| (/** @type {?Function} */ doc["webkitCancelFullScreen"])
56+
|| (/** @type {?Function} */ doc["msExitFullscreen"])
5657
|| (/** @type {?Function} */ doc["mozCancelFullScreen"])))
5758
{
5859
return null;
5960
}
6061

62+
// In theory this should not be necessary but looks like IE11
63+
// has a bug here. msFullscreenEnabled always returns true. So
64+
// this workaround also checks if msFullScreenElement is null and
65+
// returns false in this case
66+
if (doc["msFullscreenEnabled"] && !doc["msFullscreenElement"])
67+
return false;
68+
6169
// Check fullscreen state
6270
state = !!doc["fullScreen"]
6371
|| !!doc["webkitIsFullScreen"]
72+
|| !!doc["msFullscreenEnabled"]
6473
|| !!doc["mozFullScreen"];
6574
if (!state) return state;
6675

6776
// Return current fullscreen element or "true" if browser doesn't
6877
// support this
6978
return (/** @type {?Element} */ doc["fullScreenElement"])
7079
|| (/** @type {?Element} */ doc["webkitCurrentFullScreenElement"])
80+
|| (/** @type {?Element} */ doc["msFullscreenElement"])
7181
|| (/** @type {?Element} */ doc["mozFullScreenElement"])
7282
|| state;
7383
}
@@ -78,6 +88,7 @@ function fullScreen(state)
7888
// Enter fullscreen
7989
func = (/** @type {?Function} */ e["requestFullScreen"])
8090
|| (/** @type {?Function} */ e["webkitRequestFullScreen"])
91+
|| (/** @type {?Function} */ e["msRequestFullscreen"])
8192
|| (/** @type {?Function} */ e["mozRequestFullScreen"]);
8293
if (func)
8394
{
@@ -93,6 +104,7 @@ function fullScreen(state)
93104
// Exit fullscreen
94105
func = (/** @type {?Function} */ doc["cancelFullScreen"])
95106
|| (/** @type {?Function} */ doc["webkitCancelFullScreen"])
107+
|| (/** @type {?Function} */ doc["msExitFullscreen"])
96108
|| (/** @type {?Function} */ doc["mozCancelFullScreen"]);
97109
if (func) func.call(doc);
98110
return this;
@@ -150,6 +162,11 @@ function installFullScreenHandlers()
150162
change = "webkitfullscreenchange";
151163
error = "webkitfullscreenerror";
152164
}
165+
else if (e["msExitFullscreen"])
166+
{
167+
change = "MSFullscreenChange";
168+
error = "MSFullscreenError";
169+
}
153170
else if (e["mozCancelFullScreen"])
154171
{
155172
change = "mozfullscreenchange";

0 commit comments

Comments
 (0)