Skip to content

Instantly share code, notes, and snippets.

@nicksspirit
Created January 24, 2020 16:31
Show Gist options
  • Select an option

  • Save nicksspirit/9235730a5e8974837c3ec491b8008bc2 to your computer and use it in GitHub Desktop.

Select an option

Save nicksspirit/9235730a5e8974837c3ec491b8008bc2 to your computer and use it in GitHub Desktop.
Javascript function that uses the Full Screen API to display an element in fullscreen.
goFullScreen() {
const fullScreenPrefixes = [
'requestFullscreen',
'webkitRequestFullscreen',
'mozRequestFullScreen',
'msRequestFullscreen'
]
// HTMLElement is the DOM element you want to make full screen
const prefixedFn = fullScreenPrefixes.find(
prefixedFn => HTMLElement[prefixedFn] !== undefined
)
if (!prefixedFn) alert('Full Screen API is not supported in your browser')
HTMLElement[prefixedFn]()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment