24

There is a fullscreen mode in Safari on iOS. Is it possible to activate this through javascript or similar?

Thanks

Eric Herlitz
  • 25,354
  • 27
  • 113
  • 157

2 Answers2

28

No, there is no way to toggle the fullscreen mode in Safari on iOS using javascript.

In order for a web page to run in fullscreen mode, you need to add the following meta tag, and the page needs to be started from a bookmark on the home screen:

<meta name="apple-mobile-web-app-capable" content="yes">

However, you can detect if the page is running in fullscreen mode or not with javascript using the read only property:

window.navigator.standalone
Strille
  • 5,741
  • 2
  • 26
  • 40
  • 2
    https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html – Simon_Weaver Jun 19 '17 at 05:41
  • 1
    In my test window.navigator.standalone always console false in fullscreen mode and non-fullscreen mode. Its non-working answer. – Руслан Aug 11 '20 at 13:58
  • 1
    Going through the bookmark route did not work for me, but clicking the share button, then "Add to Home Screen" did. Once I open from my 'desktop' then it goes into fullscreen. – jsibs Nov 05 '20 at 21:32
  • looks like once you are in full screen mode there is no way of getting out of it? – uwe Oct 08 '21 at 17:34
1

Aftier iOS >= 12, There is only way to toggle to fullscreen through native API in Safari.

    if (document.webkitFullscreenElement) {
      document.webkitCancelFullScreen();
    } else {
      const el = document.documentElement;
      el.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
    }
lqs469
  • 395
  • 3
  • 7