I'm developing a chrome extension.
I tried to get the current window then set its width, but it doesn't work ?
Here's the code in background.js:
chrome.windows.getCurrent(
{populate: false},
function(currentWindow) {
currentWindow.width = 500;
}
);
Ans here's the manifest.json:
{
"name" : "windowresizer",
"description" : "resize current window !",
"version" : "1.0",
"manifest_version" : 2,
"background" : {
"scripts" : ["background.js"],
"persistent" : false
},
"permissions" : ["tabs"]
}
Why it doesn't work ?
I'm developing a chrome extension.
I tried to get the current window then set its width, but it doesn't work ?
Here's the code in background.js:
chrome.windows.getCurrent(
{populate: false},
function(currentWindow) {
currentWindow.width = 500;
}
);
Ans here's the manifest.json:
{
"name" : "windowresizer",
"description" : "resize current window !",
"version" : "1.0",
"manifest_version" : 2,
"background" : {
"scripts" : ["background.js"],
"persistent" : false
},
"permissions" : ["tabs"]
}
Why it doesn't work ?
You need to use the chrome.windows.update
function:
chrome.windows.getLastFocused(
{populate: false},
function(currentWindow) {
chrome.windows.update(currentWindow.id, { width: 500 });
}
);