Why trigger F11 press event doesn't work?

前端 未结 4 954
梦毁少年i
梦毁少年i 2020-12-06 11:24

I just read this question: Full Screen Page by pressing button instead of F11
The op asked to replace F11 with other hot keys, so I\'m wondering that maybe I

4条回答
  •  猫巷女王i
    2020-12-06 12:06

    Don't look at is as a question of "How do I trigger F11?" - look at is as "How do I trigger or simulate full-screen?"

    With older versions of IE you can open a new window straight into full-screen:

    window.open(someURLorOther, '', 'fullscreen=yes, scrollbars=auto');
    

    Or you can use window.open to open a new window of a specific size.

    Or you can try to resize the current window to fill the screen:

    moveTo(0,0);
    resizeTo(screen.availWidth,screen.availHeight);
    

    However just because you can doesn't mean you should. You should never resize the current window - this annoys practically everyone. Opening a new window to a size you choose is more reasonable, though if it's too big it can be annoying, and on a normal web page (where by "normal" I probably mean not some kind of browser-based data-entry app) it is nicer not to open new windows.

提交回复
热议问题