google chrome extension : how to open a new browser window more than once?

前端 未结 1 865
离开以前
离开以前 2021-01-26 09:05

My Chrome extension opens a new browser window with this simple JS:

chrome.browserAction.onClicked.addListener(function(tab) {
  var room = new Date().getTime();         


        
1条回答
  •  闹比i
    闹比i (楼主)
    2021-01-26 09:36

    window.open() is a generic JavaScript function; Chrome rate-limits it so that malicious pages can't spawn many windows.

    There is a concept of a "window name" with window.open. Since you're reusing the same one, it's not opening a new window. And the above rate-limiting still can apply.

    However, as an extension, you have access to unrestricted tools.

    Namely, take a look at chrome.windows and chrome.tabs APIs.

    chrome.windows.create({url: "fullyQualifiedURLHere"});
    

    Note that create/update methods do not require special permissions.

    0 讨论(0)
提交回复
热议问题