如何使用自动全屏模式打开网页?
我正在寻找一种在加载页面时以全屏模式自动打开网页的解决方案。 此时,单击按钮即可。
<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);
}
答案 0 :(得分:0)