1
我已經創建了一個插件,用於在Firefox上加載新選項卡,並在新選項卡的DOM上顯示一條消息。但每次我點擊新的標籤按鈕,它都會顯示消息。我想在第一個新標籤後阻止事件..我的意思是我們之後手動點擊的新標籤不應該顯示任何「hello world」消息?是否有可能..請幫助..告訴我,如果你想了解更多信息..在此先感謝..下面是我使用的代碼...如何從網頁中分離DOM事件?
var tabs = require("sdk/tabs");
tabs.open("about:blank");
tabs.on('activate', function(tab) {
var worker = tab.attach({
contentScript: 'self.port.emit("html", document.body.innerHTML = "Hello World");' // contentScript sending message to add-on script
});
worker.port.on("html", function(message) { //recieving message from contentSCript
console.log(message)
})
});
Thanx bro .. :)與往常一樣,你總是指引我走向正確的道路.. – Aksh1693