[英]Xul - javascript tabs and url
I'm training to get the address of all open tabs in firefox with no success. 我正在训练中获取Firefox中所有打开的选项卡的地址,但没有成功。 My problem is to open a tab if there's no already open, so I should search an address into tabs, and if there isn't, add one.
我的问题是要打开一个选项卡(如果尚未打开),因此我应该在选项卡中搜索一个地址,如果没有,请添加一个。
Thanks 谢谢
You have to iterate over all tabs, get the URLs and compare them. 您必须遍历所有选项卡,获取URL并进行比较。 You can get the
tabbrowser
element via the global variable gBrowser
. 您可以通过全局变量
gBrowser
获取tabbrowser
元素。
It has a property browsers
which is a NodeList of browser
elements. 它具有
browsers
属性,它是browser
元素的NodeList。
You can get the document
object of each webpage via browser.contentDocument
and then you can get the location
object, which is the URL. 您可以通过
browser.contentDocument
获取每个网页的document
对象,然后获取URL的location
对象。
So you just have to iterate over the browsers
node list and extract the URL from the location
objects. 因此,您只需要遍历
browsers
节点列表并从location
对象中提取URL。
You can add a new tab via gBrowser.addTab()
. 您可以通过
gBrowser.addTab()
添加新标签。
This might be also worth reading: Tabbed browser . 这也许也值得一读: 标签式浏览器 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.