如何使用添加SDK在打印预览firefox的工具栏中添加按钮

时间:2014-04-23 08:33:26

标签: firefox firefox-addon firefox-addon-sdk gecko

如何使用添加SDK在打印预览火狐的工具栏中添加按钮。enter image description here

非常感谢你

1 个答案:

答案 0 :(得分:1)

    function addToolbarButton() {   
        var {Cc, Ci, Cu} = require("chrome");  
    var mediator = Cc['@mozilla.org/appshell/window-mediator;1'].getService(Ci.nsIWindowMediator); 
        var document = mediator.getMostRecentWindow("navigator:browser").document; 
        var navBar = document.getElementById("print-preview-toolbar");
        if (!navBar) {
            return;
        }    
        var btn = document.createElement("toolbarbutton");       
        btn.setAttribute('type', 'button');
        btn.setAttribute('class', 'toolbarbutton-1');
        btn.setAttribute('image', data.url('print-on_small.png')); // path is relative to data folder
        btn.setAttribute('orient', 'horizontal');
        btn.setAttribute('label', '  In');
        btn.addEventListener('click', function() {  
            console.log('clicked');
        }, false)
 navBar.appendChild(btn);   
    }

done