chrome.windows.create: why callback Win is background page instead of new window?

322 views Asked by At

I am developing a chrome extension.

In background script, I create a popup window (popup.html) and I want to pass a value to a function in popup.js (which is embedded in popup.html).

chrome.browserAction.onClicked.addListener(function(tab) {
    chrome.windows.create({
        url: chrome.runtime.getURL("html/popup.html"),
        type: "popup"
    }, function(win) {
    // Do sth after window opens
        win.funcionInPopupJS(value);
    });
});

An error message is shown. Error handling response: TypeError: win.funcionInPopupJS is not a function at background.js

Why? Besides, how to call the function in popup.js?

0

There are 0 answers