HTML文件:<html><head><script type="text/javascript">function showCmd(){ alert("Ok");}</script><xml:namespace prefix="BNet"><?IMPORT namespace="BNet" implementation="a.htc"></head><body><BNet:Cmd onCmd="showCmd()">命令内容</BNet:Cmd></body></html> HTC文件:<public:component tagName="Cmd"><public:event id = "rcCmdId" name="onCmd"/><public:attach event="onmouseover" onevent="mouseOver()" /><public:attach event="onmouseout" onevent="mouseOut()" /><public:attach event="onclick" onevent="doCmd()"/><public:attach event="ondocumentready" onevent="htcInit()" /> </public:component> <script type="text/javascript">function doCmd(){ var oEvent = createEventObject(); rcCmdId.fire(oEvent);}function htcInit(){ setAttribute("__htc_changed",new Object()); }function set(prop,val){ __htc_changed[prop] = eval(prop); eval(prop + "='" + val + "'"); }function reset(){ for(var prop in __htc_changed) { eval(prop + "='" + __htc_changed[prop] + "'"); }}function mouseOver(){ set("style.color","#ff0000"); set("style.cursor","hand");}function mouseOut(){ reset();}</script> 转载于:https://www.cnblogs.com/iyond/archive/2006/03/17/352393.html