Skip to content

Instantly share code, notes, and snippets.

@ldong
Created May 14, 2017 06:18
Show Gist options
  • Save ldong/cee8330601035f09a7bceab6b9388ce0 to your computer and use it in GitHub Desktop.
Save ldong/cee8330601035f09a7bceab6b9388ce0 to your computer and use it in GitHub Desktop.
max full screen

Maximize full screen

function toggleFullscreen(e) {
  var d = document, done;
  e = e || d.documentElement;
  '-frsexit ms-FRsExit moz-FRSCancel webkit-FRsExit'.replace(/(\w*)-(f)(r)(s)(\w+)/gi, function(_, p, f, r, s, c) {
    if (!done) {
      s = 'ull' + s + 'creen';
      if (d[p + f + s + 'Element'] && d[c = p + c + 'F' + s]) {
        d[c]();
        done = 1;
      }
      else if (done = e[r = p + r + 'equestF' + s]) {
        e[r]();
      }
    }
  });
}

// http://cwestblog.com/2017/04/26/javascript-snippet-togglefullscreen/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment