我的扩展应该打开一个弹出窗口(一个普通的弹出窗口,而不是默认的扩展弹出窗口),具有以下条件:
- 此刻只能打开一扇窗,
- 我想在 localStorage 中保存窗口大小和位置,并在下次打开时恢复它们。
怎么做?
我试过了:
chrome.browserAction.onClicked.addListener(function() {
// 1. In this case, variable win is a window object. But it's empty. There
// is no properties/methods to operate with.
var win = window.open('http://example.com','windowname');
chrome.windows.create({
'url': 'http://example.com',
'type': 'popup'
}, function(win) {
// 2. In this case, variable win has some properties, but they are static
// and won't change on window resize/close.
});
});
有任何想法吗?