Pau*_*aul 5 javascript firefox jquery firefox-addon
我正在尝试使用Simple Sidebar作为基础,制作一个快速的Firefox侧边栏插件.
我正在获取当前标签网址,我希望它自动更改边栏,这样当您更改标签或网址时,侧边栏会显示相应的网页.
我一直试图改变这一行(bootstrap.js中的第56行):
bc.setAttribute('sidebarurl', URL HERE);
Run Code Online (Sandbox Code Playgroud)
我已经试过了mainWindow.content.location.href,window.location.href,gBrowser.contentWindow.location.href属性,我所能做的最好是让浏览器显示较小的浏览器侧边栏里面一个空白标签.
我无法解决我所缺少的问题,是否需要包含其他内容?
该window变量已经存在,作为 的参数传递add_elements。此窗口refers为 XUL 窗口。
由于在引导扩展中,诸如 之类的全局变量gBrowser不可用,我们将使用windowfind tabbrowser,然后使用 from tabbrowser,找到当前的 URI:
// find the tabbrowser element of window
var gBrowser = window.document.getElementById("content");
bc.setAttribute('sidebarurl', gBrowser.currentURI.spec);
Run Code Online (Sandbox Code Playgroud)