A simple library for using the JavaScript Full Screen API.

Overview

BigScreen npm

A simple library for using the JavaScript Fullscreen API.

Why should I use it?

BigScreen makes it easy to use full screen on your site or in your app. It smoothes out browser inconsistencies and bugs, especially if the element you're working with is inside of an <iframe>. It will also intelligently fall back to the older video full screen API if the element contains a <video> and the older API is available.

Download

BigScreen is ~1.4 kb minified and gzipped. Download it now.

Supported Browsers

  • Chrome 15+
  • Firefox 10+
  • Safari 5.1+
  • Internet Explorer 11
  • Opera 12.1+
  • Firefox for Android 18+
  • Chrome for Android 32

These browsers are also supported for video only:

  • Safari 5.0
  • iOS 4.2+
  • Android Browser 2.1+
  • Chrome for Android < 32

(See caniuse for always up-to-date info)

Demo

How do I use it?

Put the entire page in full screen

document.getElementById('button').addEventListener('click', function() {
	if (BigScreen.enabled) {
		BigScreen.toggle();
	}
	else {
		// fallback
	}
}, false);

Put any element in full screen

var element = document.getElementById('target');

document.getElementById('button').addEventListener('click', function() {
	if (BigScreen.enabled) {
		BigScreen.request(element, onEnter, onExit, onError);
		// You could also use .toggle(element, onEnter, onExit, onError)
	}
	else {
		// fallback for browsers that don't support full screen
	}
}, false);

Detecting full screen changes globally

BigScreen.onenter = function() {
	// called when the first element enters full screen
}

BigScreen.onchange = function() {
	// called any time the full screen element changes
}

BigScreen.onexit = function() {
	// called when all elements have exited full screen
}

Documentation

BigScreen.request(element[, onEnter, onExit, onError])

Request that an element go into full screen. If the element is falsy, the <body> will be used instead.

You can only call this from a user-initiated event, otherwise the browser will deny the request. That means key, touch, mouse, or pointer events.

In addition, if your page is inside an <iframe> it will need to have the allowfullscreen (and webkitallowfullscreen and mozallowfullscreen) attribute set on the <iframe>.

Finally, BigScreen will try to fall back to full screen for <video> if there is a child <video> in the element you pass and the browser supports it (see BigScreen.videoEnabled)). If BigScreen falls back, it will automatically load the metadata of the video so the video can enter full screen.

You can optionally pass callback functions for when this element enters or exits full screen, or if there is an error entering full screen. For all callbacks, the value of this will be set to the element that was requested. The actual element that entered full screen will be passed as the first parameter to onEnter.

BigScreen.exit()

Will exit full screen. Note that if there are multiple elements in full screen, only the last one will exit full screen.

BigScreen.toggle(element[, onEnter, onExit, onError])

Will request full screen if there is no element in full screen, otherwise it will exit full screen.

BigScreen.onenter(element)

Override to get notified when the first element goes into full screen. This will not fire if subsequent elements are added to the full screen stack (use onchange for that).

BigScreen.onchange(element)

Override to get notified any time the full screen element changes. The element that is currently displaying in full screen will be passed as the first argument.

BigScreen.onexit()

Override to get notified when fully exiting full screen (there are no more elements in full screen).

BigScreen.onerror(element, reason)

Override to get notified if there is an error sending an element into full screen. The possible values for reason are:

  • not_supported: full screen is not supported at all or for this element
  • not_enabled: request was made from a frame that does not have the allowfullscreen attribute, or the user has disabled full screen in their browser (but it is supported)
  • not_allowed: the request failed, probably because it was not called from a user-initiated event

These are the same values passed to individual onError callbacks as well.

BigScreen.element

Set to the element that is currently displaying full screen, or null if no element is in full screen.

BigScreen.enabled

A boolean that will tell you if it is possible to go into full screen. If your page is in an <iframe> it will need to have the allowfullscreen attribute set or this will be false.

BigScreen.videoEnabled(video)

Safari 5.0 and iOS 4.2+ support putting <video> into full screen. BigScreen.enabled will report false in those browsers, but you can use this to check for <video> full screen support by passing the <video> itself, or an ancestor.

This function will report false if there is no child <video>, or if it is not possible to put a <video> in full screen. It will report 'maybe' if it is possible, but the video's metadata has not been loaded, and true if it will be able to enter full screen.

Known Fullscreen API Issues

Safari 6.0 does not work properly when putting multiple elements into full screen. Open Radar bug report.

There is currently a bug in Safari (was in WebKit, but has been fixed and has been merged into Chrome as of 22) that causes the webkitfullscreenchange event to fire incorrectly when inside an iframe. BigScreen is able to work around the issue though. (Safari Bug: rdar://problem/11927884)

Links

License

BigScreen is licensed under the Apache 2.0 license. Copyright 2013 Brad Dougherty.

Comments
  • Gray screen of death in Safari when fullscreening multiple times

    Gray screen of death in Safari when fullscreening multiple times

    Hey Brad, I wanted to give you a heads up on a possible bug.

    When entering and exiting fullscreen mode multiple times in Safari, sometimes a "gray screen of death" overtakes the window. Strangely, the content begin fullscreened still seems to execute (proved, in my case, by still-playing audio from a HTML5 video) but there is no UI anymore and you can't interact with the gray screen.

    I believe this bug is separate from the layout issue you describe here: http://openradar.appspot.com/radar?id=1878403

    Here's a video: https://www.youtube.com/watch?v=PUT0OAY7S3Q

    Steps to reproduce:

    1. Go to multiple fullscreen demo page http://brad.is/reportingbugs/multiplefullscreen/
    2. Click the demo image multiple times

    I'll update this issue if I make any progress. Thank you.

    browser bug filed 
    opened by buley 5
  • Wrap Safari hack in User Agent test - Fixes #20

    Wrap Safari hack in User Agent test - Fixes #20

    • Firefox events were not being called correctly because the hack for Safari was triggering an error, which removed the element from the BigScreen instance
    opened by terramauthe 2
  • v2.0.4 throwing

    v2.0.4 throwing "addEventListener" error in IE8

    Hello,

    I'll hack around it, but I wanted to let you know that I can't just test BigScreen.enabled in IE8 because there is an unchecked use of "addEventListener" in the code that is throwing an error. Therefore BigScreen doesn't exist, and a fatal error occurs when looking for a property on the undefined object.

    Thanks!

    Noah

    bug 
    opened by noahgrant 2
  • Webkit issues with fullscreen inside a frameset

    Webkit issues with fullscreen inside a frameset

    I am using an (old fashioned) frameset (not an IFrame). One frame is supposed to host the application and allows various elements to be fullscreened

    works fine in firefox but not on webkit

    opened by WittRaider 2
  • Cannot fullscreen video in external iframe on iOS

    Cannot fullscreen video in external iframe on iOS

    My Vimeo embeds work with BigScreen on my desktop, but not on iOS.

    It looks like it fails during BigScreen.videoEnabled($('iframe)[0]). Is there a way to bypass this?

    FYI: Vimeo support states that their API does not integrate with native JS fullscreen.

    opened by firewaller 1
  • Iframe > Set Fullscreen Background Color

    Iframe > Set Fullscreen Background Color

    Having some trouble setting changing an iframe's background color to when in fullscreen mode. I understand that the default background color of the browsers visual environment is black when in fullscreen mode, but it seems it IS possible to override this with css.

    http://stackoverflow.com/questions/16163089/background-element-goes-black-when-entering-fullscreen-with-html5

    I have been trying to kung-fu this for the last day. Can someone please point me in the right direction?

    opened by baden03 1
  • Your demos no longer work in modern browsers

    Your demos no longer work in modern browsers

    Just wanted to let you know that the demos on http://brad.is/coding/BigScreen/ no longer work. It seems that you embed the JS files directly from the github repo.

    Because GitHub was sick of acting like a faux-cdn, the files are sent with a mime-type of plain/text. Modern browsers will no longer attempt to execute JS that has the wrong mime-type.

    opened by imbcmdth 1
  • BigScreen.element needs to check for all <video>s

    BigScreen.element needs to check for all

    It only checks for the one it knows about called explicitly through request(), but it's possible for a <video> to enter fullscreen automatically when it starts (for example, on the iPhone).

    I think the best way is to select all videos when element is called and check each one. That means document[fn.element] should be checked first to avoid unnecessary DOM interaction.

    enhancement 
    opened by bdougherty 1
  • Foundation 5 (with Orbit Slider) versus BigScreen

    Foundation 5 (with Orbit Slider) versus BigScreen

    Let me edit this into oblivion. Everything is working nicely... or acceptably if not perfectly. Thanks!

    (the expanding element needs something like: width: 100%; height: 100%; in order to show nicely once you hit full screen in Chrome -- not required for other browsers, where other elements can be sized)

    opened by Bonanzarama 0
  • component.json to bower.json

    component.json to bower.json

    Hello,

    I am using Brunch witch support bower components, but it demand new version of config file. 'component.json' is deprecated. It should be now 'bower.json'. And compiler of brunch has error.

    Could you change it to new supported version?

    opened by smalluban 0
  • Version 2.0.0

    Version 2.0.0

    • Adds support for individual element callbacks.
    • Cleans up and standardizes error handling.

    Also adds some automated testing (as much as can possibly be done I think). There is an iframe test page as well.

    This version doesn't address wonky behavior (I think mostly in Safari) when dealing with multiple elements in full screen. Those will be addressed in the next point release.

    opened by bdougherty 0
  • Please allow other developers to pick up your work and to continue the BigScreen story

    Please allow other developers to pick up your work and to continue the BigScreen story

    @bdougherty Brad, I understand you don't have time to continue work on this library. That's sad, but of course, it's OK Remains the question what to do with that. Would you mind to donate the library to someone else? For instance, I could step in. I'm an experienced open source developer, so I know what I'm offering. I'm offering leisure time I could use to do other things. Even so, I'd happily contribute some of my precious leisure time in order to revive your library.

    If you've not ok with this, please do these two things:

    • Take your online demo offline (bad solution), or add a notice that you've abandoned the library and send developers to one of the alternative that are still alive (better solution).
    • Add a short notice to this GitHub project that you've abandoned the project. The readme.md is a good place for that.

    Thanks in advance, Stephan

    opened by stephanrauh 0
  • [ImgBot] optimizes images

    [ImgBot] optimizes images

    Beep boop. Your images are optimized!

    Your image file size has been reduced by 3% 🎉

    Details

    | File | Before | After | Percent reduction | |:--|:--|:--|:--| | /test/src/lake.jpg | 269.08kb | 258.62kb | 3.89% | | /test/src/thumb.jpg | 40.82kb | 40.55kb | 0.66% | | | | | | | Total : | 309.89kb | 299.17kb | 3.46% |


    📝docs | :octocat: repo | 🙋issues | 🏅swag | 🏪marketplace

    opened by imgbot[bot] 0
  • Fix firefox not allowing full screen

    Fix firefox not allowing full screen

    Hi, I have the problem when firefox says "Request for full-screen was denied because Element.requestFullScreen() was not called from inside a short running" I tried without taking out the element and it works. Let me know if there is any other way to fix it.

    opened by antonelepfl 0
  • Webkit bug exiting fullscreen from within an iframe.

    Webkit bug exiting fullscreen from within an iframe.

    There's a bug on exiting full screen from within a full-screened iframe nested in a previously full-screened document. This bug shows up in Webkit browsers like Chrome or Opera (I think Safari too). For example, if I have a Youtube video in the document of an iframe, and I make a parent document containing that iframe full screen via Fullscreen API first and then click "Full screen" button in a video then I can't exit the full screen mode properly. Please, see the simplified attached code.

    fullscreen-api.zip

    Is there a way to bypass this bug?

    opened by papamurik 0
  • onenter and onexit events not being fired in Firefox 45.0

    onenter and onexit events not being fired in Firefox 45.0

    I haven't nailed down why this is happening, but these events are not being fired. This issue affects Firefox only.

    I tested this in Firefox 45.0 -- but I suspect this is happening in other versions also.

    Here is a minimum test case with jQuery that will reproduce the issue:

    function onEnterFullscreen() {
        alert("I don't fire in Firefox!");
    }
    
    function onExitFullscreen() {
        alert("I also don't fire in Firefox!");
    }
    
    $('#photo-demo img').on('click', function() {
        if (BigScreen.element !== this) {
            BigScreen.request(this, onEnterFullscreen, onExitFullscreen);
        }
        else {
            BigScreen.exit();
        }
    }); 
    

    I've tried to write a unit test to reproduce this issue, however the Unit Tests do not actually activate the Fullscreen API because use of the Fullscreen API requires User Interaction.

    It is possible to simulate User Interaction with sendEvent in PhantomJS, but other browsers will require an some sort of event handler. I haven't found a way to tell the browser that it's okay to allow Fullscreen API requests without User Interaction.

    For my purposes, I'm just going to use an onclick handler and make the test pass and use the resulting lib for my project. However, I'm wondering what solution you'd like me to implement so that the Unit Tests are actually testing the Fullscreen API. Do you use any CI tools? Is an onclick handler acceptable? Can I simulate User Interaction with PhantomJS for the CI tests if there are any?

    Thanks!

    opened by terramauthe 5
Releases(v2.0.5)
Owner
Brad Dougherty
Webmaster & roller coaster enthusiast.
Brad Dougherty
Enable full screen on for large aspect ratio screens on WhatsApp Web.

Maximize WhatsApp [WIP] Enable full screen on large aspect ratio screens on WhatsApp Web. Enable Epiphany extension. Optional if not done. Download th

null 2 Mar 13, 2022
Cast your video element to the big screen with ease!

is="castable-video" Cast your video element to the big screen with ease! The lightweight CastableVideoElement class extends the native HTMLVideoElemen

Mux 22 Jan 1, 2023
Full logging system using the djs library (v13.6.0)

Loggin-system-djs-v13.6 Full logging system using the djs library (v13.6.0) NOW ONTO MULTIPLE DISCLAIMERS: ◻ It is crucial that you first understand t

NoBoDy 12 Aug 26, 2022
A reimplementation of Winamp 2.9 in HTML5 and JavaScript with full skin support

A reimplementation of Winamp 2.9 in HTML5 and JavaScript with full skin support

Jordan Eldredge 8.9k Dec 31, 2022
Simple WhatsApp MD BOT. Get a API key from ZEN API

ALIEN ALFA-MD Contact Me: ❗❗FORK THIS BEFORE PROCEEDING Use This Button To Fork Now Scan QR Code For Session Change Session In Github ⚠️ Session Chang

TOXIC ALIEN 46 Dec 28, 2022
Simple WhatsApp Bot Script using WhatsApp Web Multi-Device API

Shiina Mashiro MD Shiina Multi Device Using NodeJS Framework & Baileys WhatsApp Web API Information WhatsApp Bot using WhatsApp Web API. If you find a

Hafidz Al-Ghifari 3 Feb 4, 2022
a full functional discord bot to send MooMoo.io bots

MooMooBot a full functional discord bot to send moomoo.io bots commands !send <server> <name> ex: !send 8:0:0 Nuro !token (generates a token to test

null 1 Jan 7, 2022
A Node JS Express/Serverless demo application that creates a slideshow video using the Pexels image library and Shotstack video editing API.

Shotstack Pexels Slideshow Video Demo This project demonstrates how to use the Shotstack cloud video editing API to create a video using an HTML form

Shotstack 25 Dec 9, 2022
Vio-MD is multi-device whatsapp bot using library @adiwajshing/baileys and example bot of Violetics API

Vio Multi Device WhatsApp Bot Use at your own risk! Build with Baileys and JavaScript's native Map class ( as a command handler ), using https://viole

Violetics 4 May 31, 2022
A Javascript library for working with Audio. It provides a consistent API for loading and playing audio on different browsers and devices. Currently supports WebAudio, HTML5 Audio, Cordova / PhoneGap, and a Flash fallback.

SoundJS SoundJS is a library to make working with audio on the web easier. It provides a consistent API for playing audio in different browsers, inclu

CreateJS 4.3k Dec 31, 2022
This is a simple web based media player for playing video and audio. Build with pure HTML, CSS and Javascript. No framework or library included.

Aim-Player This is a simple web based media player for playing video and audio. Build with pure HTML, CSS and Javascript. No framework or library incl

Aim Mikel 2 Jun 27, 2021
A simple & easy2use API for obtaining information about a discord user, discord bot or discord guild and their use for some purpose on websites!

discord-web-api A simple & easy2use API for obtaining information about a discord user, discord bot or discord guild and their use for some purpose on

InvalidLenni 2 Jun 28, 2022
Telegram-API Library Written in TypeScript

TeleLib a node js Telegram Wrapper written in TypeScript. installation yarn add @telelib/telelib or npm i --save @telelib/telelib how to use create a

MohammadMahdi Afshar 0 Jul 27, 2022
library to interact with Whatsapp's Cloud API

Whatsapp Cloud JS Whatsapp Cloud JS is a library to allows you to interact with Whatsapp's Cloud API ?? Getting started import { Client } from 'whatsa

Thalles Passos 6 Dec 5, 2022
Spotify clone using Next.js, Spotify API, Tailwind, NextAuth, Recoil

Next.js + Tailwind CSS Example This example shows how to use Tailwind CSS (v2.2) with Next.js. It follows the steps outlined in the official Tailwind

Abdelwahab Hussein 2 Dec 25, 2021
Web Application that represents a music player using the spotify API, React, JS, CSS, HTML, nodeJS, Firebase, material-ui, JSON and other technologies. Made by Yohan Hmaiti

Web Application that represents a music player using the spotify API, React, JS, CSS, HTML, nodeJS, Firebase, material-ui, JSON and other technologies. Made by Yohan Hmaiti

Yohan Hmaiti 2 Jan 8, 2022
A bot to automatically buy crypto periodically using Quidax API 🤖 💰

Quidax DCA bot This bot automatically buys crypto on your behalf on Quidax using their API while you sit back, relax and enjoy a cold one. What you ne

Edmund Ekott 18 Sep 20, 2022
GitHub action to update your discord status in a file using Lanyard API.

Discord Status Action This action fetches the status of a given user and updates that on a file. - Online - Idle - Do not disturb - Streaming - Offlin

Compey 11 Dec 15, 2022
3D visualization of music using Three.js and web audio API.

3D Music Visualization About 3D visualization of music using Three.js and web audio API Try it here Main screen Additional screen Technologies Languag

Ivan Vedenin 19 Oct 31, 2022