在Firefox扩展中添加jQuery

时间:2013-10-17 14:28:18

标签: jquery firefox firefox-addon xul browser-extension

我在stackoverflow中搜索了这个问题,但我没有找到一个好的解决方案, 所以,我的问题是,在我的扩展中,jQuery不起作用......

extension.xul:

<overlay xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'>
    <script type='application/javascript' src='chrome://extension/content/jQuery.js'></script>
    <script type='application/javascript' src='chrome://extension/content/extension.js'></script>

    <toolbar id="nav-bar">
        <toolbarbutton id="ext-toolbarbutton" label="extension" tooltiptext="extension" type="menu">
            <menupopup>
                <menuitem id="ext-toolbar-state" type="checkbox" label="Activate" accesskey="A" checked="true" oncommand="ext.disabled"/>
            </menupopup>
        </toolbarbutton>
    </toolbar>
</overlay>

extension.js

function Ext(state){
    this.state = state;
}

Ext.prototype.enable = function(){
    $("#ext-toolbar-state").attr("oncommand", "ext.disabled");
}

Ext.prototype.disabled = function(){
    $("#ext-toolbar-state").attr("oncommand", "ext.enable");
}

var ext = new Ext("enable");

谢谢!

0 个答案:

没有答案