简体   繁体   English

Xul-JavaScript标签和网址

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM