Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Full screen is not working in Safari [duplicate]

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>
like image 780
Gaurav Avatar asked Jun 13 '18 08:06

Gaurav


People also ask

How do I get Safari back to full screen?

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.

How do I get rid of double screen on Safari?

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.

How do I use F11 in Safari?

Press Control + Command + F. If your volume controls aren't bound to it, press F11.


2 Answers

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.

like image 171
user7637745 Avatar answered Oct 17 '22 14:10

user7637745


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

like image 34
Kaiido Avatar answered Oct 17 '22 15:10

Kaiido