The user has a browser action button in their Chrome extension and wants to open a custom popup window when the button is clicked. The default behavior when setting default_popup
in the manifest.json file is to show a basic popup like this:
To open a custom window, the extension listens for the chrome.browserAction.onClicked
event and decides which HTML file to open based on some computation:
chrome.browserAction.onClicked.addListener(function(tab) {
if(...)
url = "1.html";
else
url = "2.html";
chrome.windows.create({url: url, type: "popup"});
});
While this code opens a new popup window, the created window has borders and is not positioned at the location of the browser action button, unlike the default popup provided by default_popup
.
default_popup
setting and find a way to catch the event before the default popup runs, then redirect to the desired HTML file.Achieving the exact same look and feel as the default browser action popup can be challenging due to the limited customization options provided by the Chrome extension APIs. However, the solutions mentioned above can help create a custom popup window that closely resembles the default behavior.
Ask anything...