search

Home  >  Q&A  >  body text

javascript - js Make Google Chrome maximize instead of full screen (F11)

js Maximize Google Chrome instead of full screen (F11)

给我你的怀抱给我你的怀抱2791 days ago952

reply all(2)I'll reply

  • 黄舟

    黄舟2017-05-19 10:39:01

    Theoretically, js supports

    window.resizeTo( screen.availWidth, screen.availHeight );

    But in fact, each browser has different restrictions on this kind of behavior. Just imagine that you open a page and the page is directly made into full screen. That is very sad.
    Similarly restricted, there are also windows .open, continuous pop-up alerts, etc.
    This is the page permission.

    There are also browser permissions. If you are developing a chrome extension, you should not be restricted

    Additional point: Different similar trigger situations may have different results. Self-execution will have more restrictions, such as
    document.body.onload = function() {
    video.play()
    };
    Playing a video directly as soon as you enter the page is very frustrating. Some browsers restrict this type of behavior and can only use triggering:
    document.body.onclick = function() {

    video.play(); // 这就不受影响

    };

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-19 10:39:01

    function launchFullscreen(element) {
      if(element.requestFullscreen) {
        element.requestFullscreen();
      } else if(element.mozRequestFullScreen) {
        element.mozRequestFullScreen();
      } else if(element.msRequestFullscreen){
        element.msRequestFullscreen();
      } else if(element.webkitRequestFullscreen) {
        element.webkitRequestFullScreen();
      }
    }
    
    launchFullscreen(document.documentElement);

    You can refer here to learn more: http://javascript.ruanyifeng....

    However, for operations such as changing the browser size, position, and full screen, the browser believes that this should be decided by the user rather than the website developer, so this type of code is blocked by default.
    A similar prompt will appear:

    reply
    0
  • Cancelreply