监控 Firefox 侧边栏选定选项卡中的页面加载事件

发布于 2024-07-08 13:48:53 字数 112 浏览 5 评论 0原文

当主内容窗口中选定的选项卡重新加载或更改时,我希望能够在我的 Firefox 侧边栏 js 文件中运行一个函数。 因此侧边栏可以根据用户正在查看的网站而变化。

有人能指出我正确的方向吗?

I want to be able to run a function in my firefox sidebar js file when the selected tab in the main content window is reloaded or changed. So the sidebar can change depending on the site the user is looking at.

Anyone able to point me in the right direction?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不离久伴 2024-07-15 13:48:53

我的解决方案是从某个地方偷来的,但不记得在哪里:

//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"){
        }
     }
}

My solution pilfered from somewhere but can't remember where:

//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"){
        }
     }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文