javascript - 火狐 : why no change in my statusbar?

标签 javascript css firefox-addon

编辑 我有一个状态栏,可用于启用和禁用插件。

  <popupset>
  <menupopup id="inlinetransContextMenu" position="end_after">
    <image id="preficon" value="pref" />
    <menuitem id="translator-context-menuitem-preferences"
    label="preferences" onclick="alert('horay')" />
  </menupopup>
</popupset>

<!-- ========================================= -->

最佳答案

定义时:

<menupopup id="inlinetransContextMenu" position="end_after">
    <image id="preficon" value="pref" />
    <menuitem id="translator-context-menuitem-preferences"
    label="preferences" onclick="alert('horay')" />
</menupopup>

您的弹出窗口由两个元素组成,imagemenuitem。弹出窗口中的元素垂直布局,因此图像位于菜单项上方。

如果您想图像与菜单项相关联,则必须采用不同的方式,如documentation 中所述。 :
作为属性的 menuitem image它应该包含图标的路径。此外,您必须为其提供 menuitem-iconic 类才能显示图标(它是预定义的样式类(可能是 XBL 绑定(bind))):

image
Type: image URL
The URL of the image to appear on the element. If this attribute is empty or left out, no image appears. The position of the image is determined by the dir and orient attributes.

Note: The menuitem must have a class of menuitem-iconic for the image to appear.

所以你的定义应该是这样的:

<menupopup id="inlinetransContextMenu" position="end_after">
    <menuitem id="translator-context-menuitem-preferences"
              image="chrome://inlinetrans/skin/pref.png"
              class="menuitem-iconic"
              label="preferences" 
              onclick="alert('horay')" />
</menupopup>

我不明白你的其他问题:为什么当我试图抑制状态栏上的图像时,我的状态栏根本没有变化。在这种情况下,抑制 是什么意思?你想删除图标吗?还是改变?

更新:

您必须将imagelabel 设置为属性:

<statusbarpanel id="status-bar-intrans"
   context="inlinetransContextMenu"
   onclick="overlay.clickIcon(event)"
   onmouseover="var elmt=document.getElementById('status-bar-intrans');if ('enabled' == overlay.status) { elmt.tooltipText= 'inlinetrans dalam kondisi aktif';} else { elmt.tooltipText='inlinetrans dalam kondisi tidak aktif'; }">
   image="chrome://youraddon/skin/image.png"
   label="inlinetrans" />

并更改属性image。或者通过 src 和 CSS。所有这些都在 documentation 中进行了描述.

关于javascript - 火狐 : why no change in my statusbar?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4430993/

相关文章:

Javascript:为什么这个 JS 停止了?

javascript - 如何根据 javascript 变量选择输入标签的类型属性作为条件?

javascript - 为什么我的 Vue for 循环与 JSON 不起作用?

javascript - 我如何读取 Web 服务的以下 json 响应?

javascript - jquery中的选择器

javascript - 添加数据属性值作为 inline-css "width"值

javascript - 如何订阅 add-sdk 上的事件监听器?

firefox-addon - Firefox 插件中的 URL 匹配模式

javascript - Kendo UI - 文本颜色更改点击取消

html - 我如何让我的 Opera 浏览器运行鼠标指针