Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including fullscreen with all npm packages installed. Try it out:

var fullscreen = require("fullscreen")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

fullscreen v1.1.1

fullscreen polyfill api that presents an event emitter


polyfill for requestFullscreen

var fullscreen = require('fullscreen')
  , el = document.getElementById('element')
  , fs

fs = fullscreen(el)

el.addEventListener('click', function() {

document.body.onkeydown = function() {

fs.on('attain', function() {
  // attained fullscreen

fs.on('release', function() {
  // released fullscreen

fs.on('error', function() {
  // fullscreen request failed, or
  // fullscreen isn't supported


require('fullscreen').available() -> bool

return a boolean yes/no for whether fullscreen api is supported.

require('fullscreen').enabled() -> bool

return a boolean yes/no for whether fullscreen is enabled for the document.

fullscreen(element) -> fs event emitter

return a fullscreen event emitter object. if fullscreen is not available, on the next turn of the event loop it'll emit 'error'.

fs.request() -> undefined

issue a request for fullscreen. if it's accepted, it emits 'attain', otherwise 'error' for denial.

fs.release() -> undefined

release the current fullscreen element. if the fullscreen is released, it emits 'release'.

fs.dispose() -> undefined

removes any event listeners created by the fs instance once you're done with it. -> HTMLElement?

returns the current fullscreen target, if any.




RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free