当主内容窗口中的选定选项卡被重新加载或更改时,我希望能够在我的 firefox 边栏 js 文件中运行一个函数。因此侧边栏可以根据用户正在查看的站点而改变。
谁能给我指出正确的方向?
最佳答案
我的解决方案是从某处窃取的,但不记得在哪里:
//add the load eventListener to the window object
window.addEventListener("load", function() { functioname.init(); }, true);
var functionname = {
//add the listener for the document load event
init: function() {
var appcontent = document.getElementById("appcontent"); // browser
if(appcontent)
appcontent.addEventListener("DOMContentLoaded", functionname.onPageLoad, false);
},
//function called on document load
onPageLoad: function(aEvent) {
if(aEvent.originalTarget.nodeName == "#document"){
}
}
}
关于javascript - 从 firefox 侧边栏监视选定选项卡中的页面加载事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/246274/