[英]How to get unique tabId for the browser on the firefox addon
在我的firefox插件中,我正在使用選項卡,請遵循以下鏈接: https : //developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/tabbrowser 。
我需要為每個標簽確定唯一的ID(tabId)。 例如,
index | tabId | tabLink
1 | 11AA | example1.com
2 | 11BB | example2.com
3 | 11CC | example1.com
我對tabId字段有疑問,如何為每個標簽獲取唯一的tabId?
謝謝
這就是我測試的方式: http : //i.imgur.com/dV6Cj3J.png
最初,選項卡上沒有唯一的ID。 您需要做的就是抓取標簽,例如var aTab = gBrowser.tabContainer.childNodes[0]
(抓取第一個標簽),然后像aTab.setAttribute('myCustAttr', 'myCustVal123')
一樣在其上設置setAttribute
,然后將來可以通過訪問var thatTab = document.querySelector('[myCustAttr="myCustVal123"]')
來獲取該標簽
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.