0

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

扩展名.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>

扩展.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");

谢谢 !

4

0 回答 0