css - 为什么这个 XBL 示例不起作用?

标签 css xml xul xbl

这个例子来自this Mozilla's page .

ma​​in.xul

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="main.css" type="text/css"?>

<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

    <box id="num" class="labeledbutton" title="Number of Things:" value="52"/>

    <button label="Show" oncommand="document.getElementById('num').showTitle(true)"/>
    <button label="Hide" oncommand="document.getElementById('num').showTitle(false)"/>
</window>

ma​​in.css

box.okcancelbuttons {
    -moz-binding: url('main.xml#labeledbutton');
}

ma​​in.xml

<?xml version="1.0"?>
<binding id="labeledbutton">
  <content>
    <xul:label xbl:inherits="value=title"/>
    <xul:label xbl:inherits="value"/>
  </content>
  <implementation>
    <method name="showTitle">
      <parameter name="state"/>
      <body>
        if (state) document.getAnonymousNodes(this)[0].
          setAttribute("style","visibility: visible");
        else document.getAnonymousNodes(this)[0].
          setAttribute("style","visibility: collapse");
      </body>
    </method>
  </implementation>
</binding>

为什么点击按钮时没有显示框?

最佳答案

试试吧

XUL(main.xul)

<box id="num" class="labeledbutton" title="Number of Things:" value="52"/>

<button label="Show" oncommand="document.getElementById('num').showTitle(true)"/>
<button label="Hide" oncommand="document.getElementById('num').showTitle(false)"/>

CSS(main.css)

box.okcancelbuttons {
    -moz-binding: url('main.xbl#labeledbutton');
}

XBL(main.xbl)

<?xml version="1.0"?>
<bindings xmlns="http://www.mozilla.org/xbl"
          xmlns:xbl="http://www.mozilla.org/xbl"
          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 <binding id="labeledbutton">
  <content>
    <xul:label xbl:inherits="value=title"/>
    <xul:label xbl:inherits="value"/>
  </content>
  <implementation>
    <method name="showTitle">
      <parameter name="state"/>
      <body>
        if (state) document.getAnonymousNodes(this)[0].
          setAttribute("style","visibility: visible");
        else document.getAnonymousNodes(this)[0].
          setAttribute("style","visibility: collapse");
      </body>
    </method>
  </implementation>
 </binding>
</bindings>

关于css - 为什么这个 XBL 示例不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3687686/

相关文章:

html - 去除标题中的空格(HTML、CSS 相关)

css - 使用 CSS 将图像的一部分变灰

Python - 将 xml 中的特定行转换为小写并写回 - utf-8 问题

xml - <xsl :copy-of copying the namespace present in the root node . 如何避免这种情况?

javascript - 从 DIV 获取 GoogleDocs 选择并替换它(JAVASCRIPT、XUL)

javascript - XUL。 Tree.为什么子项会掉落?

html - 有没有办法只为 child 而不是孙子申请 css?

html - 输入中的 Bootstrap 字形图标在悬停时不显示

android - Android 上的 SaxParser : Unexpected End Of Document Exception

javascript - 如何在 Firefox 插件脚本中访问 DOM?