本文介绍了谷歌浏览器扩展:如何不止一次打开一个新的浏览器窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的Chrome扩展程序通过这个简单的JS打开一个新的浏览器窗口:
chrome.browserAction.onClicked.addListener(function( tab){
var room = new Date()。getTime();
win = window.open(http://www.example.com/page.html#+ room,win ,width = 485,height = 55);
});
这很好,但只有一次。
我也试过这个(没有成功):
win .location =http://www.example.com/page.html#\"+room;
win.location.reload();
解决方案
window.open() 是一个通用的JavaScript函数;
There is a concept of a "window name" with window.open
. Since you're reusing the same one, it's not opening a new window. And the above rate-limiting still can apply.
However, as an extension, you have access to unrestricted tools.
Namely, take a look at chrome.windows
and chrome.tabs
APIs.
chrome.windows.create({url: "fullyQualifiedURLHere"});
Note that create
/update
methods do not require special permissions.
这篇关于谷歌浏览器扩展:如何不止一次打开一个新的浏览器窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!