Prevent esc from exiting fullscreen mode

前端 未结 2 481
遥遥无期
遥遥无期 2020-12-04 03:46

My webpage converted to full screen mode using this following code.

    var element = document.getElementById(\"b\");


    if (element.mozRequestFullScreen)         


        
相关标签:
2条回答
  • 2020-12-04 04:33

    Any browsers complying to the standards will not (and should not) let you block this. Quite simply because it would be very intrusive and will confuse the users, who expect to always have a clear "panic button" to escape a screen.

    Here are the api specifications:
    Mozilla Developer Network
    W3C

    0 讨论(0)
  • 2020-12-04 04:34

    That's impossible from pure js. The API is designed to allow the user to exit the fullscreen mode at any time.

    The only thing cou can try is to use the fullscreenchange event to detect when the fullscreen is disabled, and then enable it again. But the browser will probably alert the user and he will always be able to disallow your website to use fullscreen.

    I don't encourage you to do it. That's really a bad idea. I would probably ragequit (and never return) a website which tries that.

    0 讨论(0)
提交回复
热议问题