开发者

Firefox get unique id of tabs for extension development

I'm developing a Firefox extension, and I need get and work with unique id of tabs.

How I can开发者_C百科 do it?

Thanks!


If you use the Firefox SDK, you can get the id of the active tab by using:

var tabs = require('sdk/tabs');
var activeTabId = tabs.activeTab.id;


I have a solution. You can try this out. The function below will return you a unique id of the current tab.

var get_current_tab_id = function()
        {
            var doc = gBrowser.contentDocument; //Gets the current document.
            var tab = null;
            var targetBrowserIndex = gBrowser.getBrowserIndexForDocument(doc);
            if (targetBrowserIndex != -1)
            tab = gBrowser.tabContainer.childNodes[targetBrowserIndex];
            else
            return(null);
            return(tab.linkedPanel);
        }


Check out the documentation for nsIWindowMediator, which provides information and access to all open windows within Firefox.

https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIWindowMediator#getEnumerator


If you mean that you want to interact in any way with the open firefox tabs via javascript then the answer is that you cannot.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜