Home > Net >  JS, how to run automatically webkitRequestFullscreen
JS, how to run automatically webkitRequestFullscreen

Time:11-06

I want to open a browser automatically full-screen, but I perform document. The documentElement. WebkitRequestFullscreen (); Will an error "Failed to execute 'requestFullscreen' on 'Element: API can only be initiated by a user gesture" and click on the BUTTON event method can run normally, simulate the click event is useless, the same error, but sometimes the line again? Is page back to a few times and can be full screen automatically, don't know how to achieve specific, a great god help
 & lt; The button id="fullScreen" onclick="fullScreen ()" & gt;  


 $(" # fullScreen "). The trigger (" click "); 
The function fullScreen () {
The debugger
Var element=document. DocumentElement;
If (element. RequestFullscreen) {
Element. RequestFullscreen ();
{} else if (element msRequestFullscreen)
Element. MsRequestFullscreen ();
{} else if (element mozRequestFullScreen)
Element. MozRequestFullScreen ();
{} else if (element webkitRequestFullscreen)
Element. WebkitRequestFullscreen ();
}
}

CodePudding user response:

Window. The onl oad=function () {
$(" # fullScreen "). The trigger (" click ");
}

It's no use also tried
  •  Tags:  
  • C#