下面是一个更简单的例子来说明这个失败(它应该在按下“z”后隐藏img,在按下“x”后显示img):
我的测试.xul:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="chrome://test/content/test.css" type="text/css"?>
<window id="desktop" width="640" height="480"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<image id="img" src="image.png" flex="1"/>
</window>
#desktop { -moz-binding: url("chrome://test/content/test.xml#desktop"); }
我的test.xml:
<?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">
<!-- Desktop binding & Key handlers -->
<binding id="desktop">
<handlers>
<handler event="keypress" key="Z" >
<![CDATA[
var img = getElementById("img");
if(img)
img.hidden = true;
]]>
</handler>
<handler event="keypress" key="X" >
<![CDATA[
var img = getElementById("img");
if(img)
img.hidden = false;
]]>
</handler>
</handlers>
</binding>
</bindings>
它藏起来后就不露了,知道怎么修吗?这是一个xulrunner虫吗?我用xulrunnet 1.9.2.12运行它。