问题描述
我正在开发一个Chrome扩展。
我试图获取当前窗口,然后设置它的宽度,但它不起作用吗?
以下是background.js中的代码:
chrome.windows.getCurrent(
{populate:false},
函数(currentWindow){
currentWindow.width = 500;
}
);
回答manifest.json:
{
name:windowresizer,
description:调整当前窗口的大小!,
version:1.0,
manifest_version:2,
background:{
scripts:[background.js],
persistent:false
},
permissions:[tabs]
}
't work?
您需要使用 I'm developing a chrome extension. Here's the code in background.js: Ans here's the manifest.json: Why it doesn't work ? You need to use the 这篇关于如何在Chrome扩展中设置当前窗口的宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! chrome.windows.update $ c $
$ p $ chrome.windows.getLastFocused(
{populate:false},
function( currentWindow){
chrome.windows.update(currentWindow.id,{width:500});
}
);
I tried to get the current window then set its width, but it doesn't work ?chrome.windows.getCurrent(
{populate: false},
function(currentWindow) {
currentWindow.width = 500;
}
);
{
"name" : "windowresizer",
"description" : "resize current window !",
"version" : "1.0",
"manifest_version" : 2,
"background" : {
"scripts" : ["background.js"],
"persistent" : false
},
"permissions" : ["tabs"]
}
chrome.windows.update
function:chrome.windows.getLastFocused(
{populate: false},
function(currentWindow) {
chrome.windows.update(currentWindow.id, { width: 500 });
}
);