How can I make a chrome packaged app which runs in fullscreen at startup?

后端 未结 6 886
悲&欢浪女
悲&欢浪女 2021-02-14 06:39

Currently it seems that the fullscreen ability can only be activated from a user action (mouse/keyboard event). Is there a way to circumvent this?

6条回答
  •  隐瞒了意图╮
    2021-02-14 07:35

    You can use the HTML5 Fullscreen API, which requires a user action:

    button.addEventListener('click', function() {
      document.body.webkitRequestFullscreen();
    });
    

    or the more "app-y" way using the AppWindow object, which doesn't require a user action:

    chrome.app.window.current().fullscreen();
    

    Both need the "fullscreen" permission in the manifest.json.

提交回复
热议问题