Full screen is working in chrome and other browsers but not working in Safari. Here is my code:
var doc = window.document;
var docEl = document.getElementById("divId");
//doc.documentElement;
var requestFullScreen = docEl.requestFullscreen || docEl.mozRequestFullScreen || docEl.webkitRequestFullScreen || docEl.msRequestFullscreen;
var cancelFullScreen = doc.exitFullscreen || doc.mozCancelFullScreen || doc.webkitExitFullscreen || doc.msExitFullscreen;
if(!doc.fullscreenElement && !doc.mozFullScreenElement && !doc.webkitFullscreenElement && !doc.msFullscreenElement){
requestFullScreen.call(docEl);
} else {
cancelFullScreen.call(doc);
}
<div id="divId" style="width: 300px;height:60px" > FULL SCREEN </div>
Fullscreen mode on a Mac computer To set an Internet browser like Safari to fullscreen mode on a macOS computer, press Command + Control + F . To exit fullscreen mode, press Command + Control + F again. In full-screen mode on a Mac, the browser's address bar and toolbars are still displayed.
To close Split View, tap the Multitasking button in the Safari window that you want to keep, then tap the full screen button . Or you can drag the app divider left or right over the Safari window that you want to close.
Press Control + Command + F. If your volume controls aren't bound to it, press F11.
The Fullscreen API is not supported in iOS Safari and has partial support in Safari: more on this.
I would recommend to check out Sindre's cross-browser wrapper, screenfull.js around the Fullscreen API, at least check out the source and get what your current project needs.
If you create a web app, that your users will install, here you can find out more about certain meta tags to specify in order to run your web app in full-screen.
It is Element.webkitRequestFullscreen
, lower-case s
in Fullscreen.
Only Firefox did set their vendor-prefixed version with a camel-cased FullScreen, probably to make everyone's life harder...
var requestFullScreen = docEl.requestFullscreen || docEl.webkitRequestFullscreen || docEl.mozRequestFullScreen || docEl.msRequestFullscreen;
As a fiddle since StackSnippets' iframes don't allow fullscreen
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With