Skip to content

Instantly share code, notes, and snippets.

@kcliu
Created November 26, 2012 04:13
Show Gist options
  • Save kcliu/4146575 to your computer and use it in GitHub Desktop.
Save kcliu/4146575 to your computer and use it in GitHub Desktop.
/*
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