Why [removed] = launchFullscreen(document.documentElement); not work?

后端 未结 3 608
礼貌的吻别
礼貌的吻别 2020-12-22 12:09

I use launchFullscreen() function for get page full screen. It\'s work perfect with button onClick.But It doesn\'t work with window.onload

3条回答
  •  一个人的身影
    2020-12-22 12:46

    I work around the "must be user action" by binding it to a click event on the HTML element.

    $('html').click( function() {
      if(!document.fullscreenElement){
        $('html')[0].requestFullscreen();
      }
    });
    

    You just need to remember to touch something once it is loaded. Even if you forgot, the first click will put the page to full screen.

    p.s.: Yes, you can easily do this without using jQuery by using proper getElement... functions.

提交回复
热议问题