onload网站应全屏显示 [英] onload website should display fullscreen
问题描述
我在使用HTML CSS JavaScript和jQuery的网站上工作.我想全屏显示网站(例如,当我们单击F11时).我什至可以使用onclick进入全屏模式.但是使用onload事件时,全屏脚本无法正常工作.当我加载一个网站时,它应该以全屏显示.请帮忙.这是我的代码:这是我的HTML代码:
hi i am working on a website using HTML CSS JavaScript and jQuery. I wanted to display website fullscreen(like when we click F11) onload. I am able to enter fullscreen using onclick even. But with onload event fullscreen script is not working. When i load a site it should display in fullscreen. please help. Here is my code : here is my HTML code:
<html id="player3">
<body onload="goFullscreen('player');">
</body>
</html>
这是我的js
function goFullscreen() {
var element = document.getElementById("player3");
if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if (element.webkitRequestFullScreen) {
element.webkitRequestFullScreen();}
}
推荐答案
浏览器不允许网站在没有用户交互的情况下以全屏模式加载.您将收到以下错误消息
Browsers doesn't allow sites to load in fullscreen mode without user interaction. You will get the following error message
无法在元素"上执行"requestFullScreen":API只能通过用户手势启动.
Failed to execute 'requestFullScreen' on 'Element': API can only be initiated by a user gesture.
要处理此问题,请更改您的用户体验,以使用户与您的网站进行互动以进入全屏模式.
To Handle this change your UX to make the user interact with your site to go fullscreen mode.
这篇关于onload网站应全屏显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!