无法使用chrome.app.window.get获取chrome.window实例
Cannot get chrome.window instance with chrome.app.window.get
当我点击按钮时,我正在尝试以下代码:
chrome.app.window.create('sample.html', {
id: 'test',
'bounds': {
'width': 200,
'height': 200
},
'resizable' : false,
'frame': { type: "none" }
})
console.debug(chrome.app.window.getAll())
var windowcreated = chrome.app.window.get('test');
windowcreated.innerBounds.height = 50;
windowcreated.innerBounds.width = 200;
但控制台上写着:
未捕获的类型错误:无法读取空的属性"innerBounds"
getAll()的调试只返回我在background.js中创建的原始窗口。。。
chrome.app.window.create()
是异步的。
当执行到达chrome.app.window.get('test')
时,该窗口还不存在。
您需要在chrome.app.window.create
:的回调中移动您的逻辑
chrome.app.window.create('sample.html', {
id: 'test',
'bounds': {
'width': 200,
'height': 200
},
'resizable' : false,
'frame': { type: "none" }
}, function(createdWindow) {
// Do stuff here, and no need for get()
createdWindow.innerBounds.height = 50;
createdWindow.innerBounds.width = 200;
});
相关文章:
- window.location使用jquery mobile实现chrome跳转
- javascript window.open将无法在Chrome控制台上工作
- window.location.htm无法在chrome扩展中工作
- window.opener not working in chrome & IE
- 强制 window.open() 在 chrome 中创建新选项卡
- window.close();在Chrome和Firefox中不起作用
- window.location.hash = “”;强制在Chrome和Safari上重新加载框架集
- window.onbeforeunload在IE8中不触发(在Firefox,Chrome和Safari中工作正常)
- window.open在chrome扩展中返回undefined
- window.clipboardData.getData(“文本”)在chrome中不起作用
- window.open在firefox上工作,而不是在chrome上
- window.showmodaldialog在chrome中不起作用
- 无法在Chrome中捕获Chrome window.location.href
- ie与chrome window.location.href和<基本>标签
- MS Edge有一个window.chrome对象??破坏浏览器检测
- window.open在chrome中不起作用
- Chrome在window.open()之后同步选项卡
- window.history.go(-1)无法在Chrome中工作
- window.frames.length在chrome和Firefox浏览器中返回0
- 做window.chrome检测手机chrome