Chrome Extension Maximize Current Window

雨燕双飞 提交于 2020-01-06 03:54:12

问题


I understand that directions on how to manipulate windows are found here. But I'm having a hard time following along and would greatly appreciate if someone could explain, for example, how to maximize the current window.

I know how to use the chrome.windows functions to create a window, but I'm not sure how to use the same functions to manipulate an existing window.

I know that I need to set WindowState to maximized. I just cant figure out how to do so inside of an action script.


回答1:


You could try to use chrome.windows.update:

chrome.windows.update(yourWindowId,{state:"maximized"},function(windowUpdated){
    //do whatever with the maximized window
});

You can get the window's id using chrome.windows.getCurrent, chrome.windows.getLastFocused or chrome.windows.getAll




回答2:


In case you are using a multi-monitor setuo, you need to cascade the calls from the creation because the max mode applies where the window is currently located, therefore, its best to chrome.windows.create in any monitor you may like and then to set the maximized state with the chrome.windows.update.

chrome.windows.create(createData, function onCreated(window) {
        console.log('Created');
        chrome.windows.update(window.id, {state:'maximized'}, function onUpdated() {
          console.log('Maximized');
        });
      }
    });


来源:https://stackoverflow.com/questions/37644098/chrome-extension-maximize-current-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!