Created
November 26, 2012 04:13
-
-
Save kcliu/4146575 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
support FullScreenMode | |
*/ | |
var FullScn = { | |
enterFullScn: function() | |
{ | |
var e = document.getElementById("fullscreen-wrapper"); | |
if (FullScn.RunPrefixMethod(document, "FullScreen") || FullScn.RunPrefixMethod(document, "IsFullScreen")) { | |
FullScn.RunPrefixMethod(document, "CancelFullScreen"); | |
} | |
else { | |
FullScn.RunPrefixMethod(e, "RequestFullScreen"); | |
} | |
}, | |
//cross-browser compatibility | |
RunPrefixMethod: function(obj, method) | |
{ | |
var pfx = ["webkit", "moz", "ms", "o", ""]; | |
var p = 0, m, t; | |
while (p < pfx.length && !obj[m]) { | |
m = method; | |
if (pfx[p] == "") { | |
m = m.substr(0,1).toLowerCase() + m.substr(1); | |
} | |
m = pfx[p] + m; | |
t = typeof obj[m]; | |
if (t != "undefined") { | |
pfx = [pfx[p]]; | |
return (t == "function" ? obj[m]() : obj[m]); | |
} | |
p++; | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment