Open webpage in fullscreen in Safari on iOS

前端 未结 2 1538
执念已碎
执念已碎 2021-01-01 20:43

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

Thanks

相关标签:
2条回答
  • 2021-01-01 21:12

    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
    
    0 讨论(0)
  • 2021-01-01 21:24

    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);
        }
    
    0 讨论(0)
提交回复
热议问题