简体   繁体   中英

Fullscreen in Safari for iPad, iPhone

What would be the code for fullScreen and cancelFullScreen in Safari, following this code?:

var docEl = document.documentElement;

if      (docEl.requestFullScreen)       docEl.requestFullScreen();
else if (docEl.msRequestFullscreen)     docEl.msRequestFullscreen();
else if (docEl.mozRequestFullScreen)    docEl.mozRequestFullScreen();
else if (docEl.webkitRequestFullScreen) docEl.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);

Change your body id to 'body'and Try this

<script type="text/javascript">
var is_safari = navigator.userAgent.indexOf("Safari") > -1;
      var elem = document.getElementById("body");

if((navigator.userAgent.match(/iPhone/i)) || 
 (navigator.userAgent.match(/iPod/i))) {
  if (is_safari){

    elem.onclick = function() {
        req = elem.requestFullScreen || elem.webkitRequestFullScreen || elem.mozRequestFullScreen;
        req.call(elem);
    }
    }
 }
 $(document).keyup(function(e) {
     if (e.keyCode == 27) { // escape key maps to keycode `27`
 elem.webkitExitFullScreen();
    }
});
 </script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM