How to open chrome-extension in new tab by default? Not in the new pop-up as like the present time.
I have the:
//manifest.json
{
...
"background": {
"scripts": ["js/background.js"],
"persistent": false
},
"browser_action": {
"default_title": "Test Viewer v.1.0",
"default_icon": "icon.png",
"default_popup": "index.html"
},
"permissions": [
"unlimitedStorage",
"notifications",
"activeTab",
"tabs",
"/*",
"downloads"
]
...
}
and
//background.js
chrome.browserAction.onClicked.addListener(function(tab){
chrome.tabs.create({
url: ("index.html"),
type: "normal"
});
});
In the docs this type is specified as type: "normal"
which open the "normal browser window" as I wish, but it doesn't work.
Where is error?
How to open chrome-extension in new tab by default? Not in the new pop-up as like the present time.
I have the:
//manifest.json
{
...
"background": {
"scripts": ["js/background.js"],
"persistent": false
},
"browser_action": {
"default_title": "Test Viewer v.1.0",
"default_icon": "icon.png",
"default_popup": "index.html"
},
"permissions": [
"unlimitedStorage",
"notifications",
"activeTab",
"tabs",
"https://docs.google./*",
"downloads"
]
...
}
and
//background.js
chrome.browserAction.onClicked.addListener(function(tab){
chrome.tabs.create({
url: ("index.html"),
type: "normal"
});
});
In the docs https://developer.chrome./extensions/windows this type is specified as type: "normal"
which open the "normal browser window" as I wish, but it doesn't work.
Where is error?
2 Answers
Reset to default 41) I have deleted default_popup
property in manifest.json
by advice @Josh Lee and 2) use this code in background.js
:
chrome.browserAction.onClicked.addListener(function(tab){
chrome.tabs.create({
'url': chrome.runtime.getURL("index.html#window")
});
});
Get rid of default_popup
. The presence of this attribute declaratively means you want to open your extension's popup when clicked.
As long as the browser_action
section is present at all, you can use the chrome.browserAction.onClicked
event to run your handler.