简体   繁体   English

自动加载全屏模式

[英]Auto load full screen mode

How to open a web page using auto full screen mode?如何使用自动全屏模式打开网页?

I am looking for a solution to open an web page automatically in full screen mode, when page is loaded.我正在寻找一种在加载页面时以全屏模式自动打开网页的解决方案。 At this moment I can do it when I clicked a button.此时我可以通过单击按钮来完成。

<body onload="myFunction()">
<h1>Screen Orientation Lock Demo</h1>
<button class="lock">Lock</button>
  <textarea></textarea>
</body>


var fullscreen = {
  request: function(elem){
    if (elem.requestFullscreen) {
      elem.requestFullscreen();
    } else if (elem.msRequestFullscreen) {
      elem.msRequestFullscreen();
    } else if (elem.mozRequestFullScreen) {
      elem.mozRequestFullScreen();
    } else if (elem.webkitRequestFullscreen) {
      elem.webkitRequestFullscreen();
    }
  },
};


$('.lock').on('click', function() {
  fullscreen.request(this.parentNode);
});

function myFunction() {
    fullscreen.request(this.parentNode);
}

As per documentation :根据文档

This method must be called while responding to a user interaction or a device orientation change;在响应用户交互或设备方向更改时必须调用此方法; otherwise it will fail.否则会失败。

So, the requestFullScreen method should be called after a user interaction with the page or on orientation change.因此,应该在用户与页面交互或方向更改后调用requestFullScreen方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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