【问题标题】:Change Javascript in a Firefox extension overlay在 Firefox 扩展覆盖中更改 Javascript
【发布时间】:2012-09-15 18:48:09
【问题描述】:

我为 Firefox 编写了一个带有覆盖的扩展。

当我点击主按钮时,扩展加载entconnect.entImmediat,但是当我点击“Changez vos identifiants”时,扩展加载entconnect.openLogs AND entconnect.entImmediat。当我单击“Changez vos identifiants”时,如何仅加载 entconnect.openLogs? 这是我的叠加层代码:

<overlay id="entconnect-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="chrome://entconnect/content/entconnect.js"/>
<toolbarpalette id="BrowserToolbarPalette">
    <toolbarbutton class="toolbarbutton-1 chromeclass-toolbar-additional" id="entconnect-addbar" label="Allez sur votre ENT" type="menu-button" oncommand="entconnect.entImmediat();">
        <menupopup>
            <menuitem label="Changez vos identifiants" oncommand="entconnect.openLogs();"/>
        </menupopup>                             
    </toolbarbutton>
</toolbarpalette>
</overlay>

【问题讨论】:

    标签: javascript firefox firefox-addon dom-events xul


    【解决方案1】:

    命令事件冒泡意味着它将被 DOM 层次结构中更上层的事件处理程序接收。如果您已经处理过,可以prevent the event from bubbling further up:

    oncommand="entconnect.openLogs();event.stopPropagation();"
    

    或者你可以看看event target:

    oncommand="if (event.target.localName != 'menuitem') entconnect.entImmediat();"
    

    或者你可以只处理triggered at the current element的事件:

    oncommand="if (event.eventPhase == event.AT_TARGET) entconnect.entImmediat();"
    

    【讨论】:

    猜你喜欢
    • 2011-02-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多