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

后端 未结 6 890
悲&欢浪女
悲&欢浪女 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:28

    Edit: Per BeardFist's comment, my original answer was wrong on two fronts. You can do this on a Chrome Extension (which this is tagged as), but probably not on a packaged app.

    For extensions you can make it go fullscreen using the state:"fullscreen" option, which can be applied with chrome.window.update. The code below chains the creation of the window via chrome.windows.create with chrome.window.update. In my experiments you could not set the fullscreen state directly through the window creation.

    chrome.windows.create(
      {url:"PATH/TO/POPUP"}, 
        function(newWindow) {
            chrome.windows.update(newWindow.id, {state:"fullscreen"})
    });
    

提交回复
热议问题