我尝试添加一个新的按钮到Firefox,但它是旧的按钮被添加! [英] I try to add a new button to Firefox, but it's the old button that gets added!

查看:116
本文介绍了我尝试添加一个新的按钮到Firefox,但它是旧的按钮被添加!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一次,我尝试添加一个带有书签项目pagerank的按钮作为PersonalToolbar的类。现在,代码...

Once, I tried adding a button with "bookmark-item pagerank" as class to PersonalToolbar. Now, the code...

function createToolbarButton() {
    const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
    var anitem = document.createElementNS(XUL_NS, "toolbarbutton");
    anitem.setAttribute("id", "Testing-Doit-Button2");
    anitem.setAttribute("class", "toolbarbutton-1 chromeclass-toolbar-additional pagerank");
    anitem.setAttribute("label", "PageRank");
    anitem.setAttribute("tooltiptext", "Do it!");
    anitem.setAttribute("oncommand", "testing_doit();");
    return anitem;
}
function placeToolbarButton() {
    var bar = document.getElementById("nav-bar");
    var newitem = createToolbarButton();
    bar.appendChild(newitem);
}
placeToolbarButton();

...添加一个带有书签项目页面的按钮,而不是toolbarbutton-1 chromeclass-工具栏附加pagerank作为PersonalToolbar而不是nav-bar的类!

...adds a button with "bookmark-item pagerank" instead of "toolbarbutton-1 chromeclass-toolbar-additional pagerank" as class to PersonalToolbar instead of nav-bar!

如何解决这个问题?

已更新!我没有注意到功能名称还是旧的!我想创建并放置一个工具栏按钮,而不是书签项!对不起!

UPDATED! I hadn't noticed that the function names were still the old ones! I want to create and place a toolbar button, not a bookmark item! I'm sorry!

推荐答案

现在,它的作品!在Javascript Shell中,在button.js中键入与其他函数相同名称的函数,并且hiting enter即使它们有不同的行为,也将调用button.js中的函数

Now, it works! In the Javascript Shell, typing a function with the same name as an other function in button.js and hiting enter, even if they have different behaviors, will call the function in button.js

顺便说一下,要使用Javascript Shell,您必须安装Extension Developer的扩展,然后去Firefox - >工具 - > ExtensionDeveloper - > Javascript Shell - > enumerateWindows() - > chrome://浏览器/内容/ browser.xul

By the way, to use the Javascript Shell the way I used, you have to install Extension Developer's Extension, then go Firefox -> Tools -> ExtensionDeveloper -> Javascript Shell -> enumerateWindows() -> chrome://browser/content/browser.xul

这篇关于我尝试添加一个新的按钮到Firefox,但它是旧的按钮被添加!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆