Reputation: 5716
I'm trying to use chrome.create.window to get a popup window and something goes wrong.
Here's my background.js code:
chrome.extension.onRequest.addListener(function(request) {
if (request.type === 'open_window') {
chrome.tabs.create({
url: chrome.extension.getURL('win.html'),
active: false
}, function(tab) {
chrome.windows.create({
tabId: tab.id,
type: 'popup',
height: '200',
focused: true
});
});
}
});
Before I've added height: '200',
I got what I wanted: a window jumped out of the browser. When I add this line, the window opens as another tab of the opened window. Why is it ?
Upvotes: 1
Views: 932
Reputation: 349142
Use a number instead of a string:200
→ "200"
. You would know that if you opened the console for the background page:
Uncaught Error: Invalid value for argument 1. Property 'height': Expected 'integer' but got 'string'.
I suggest to use the url
option with chrome.windows.create
, because it's slightly more efficient:
chrome.windows.create({
url: chrome.extension.getURL('win.html'),
type: 'popup',
height: 200,
focused: true
});
Upvotes: 2