<head>
<public:component tagName="mydiv">
<public:attach event="oncontentready" onevent="f_contentReady()" />
<public:defaults viewLinkContent="true" />
</public:component><script language="JScript">
function f_contentReady()
{
defaults.viewLink = document;
}function divClicked()
{
window.setTimeout("window.document.all."+element.id+".alertMess()", 1000);
}function alertMess()
{
alert("This is a div.");
}
</script></head>
<body>
<div onclick='divClicked();'>my div</div>
</body>
<html xmlns:wc="webcontrols">
<head>
<?IMPORT namespace="wc" implementation="mydiv.htc">
</head>
<body>
<wc:mydiv id="aa"></wc:mydiv>
</body>
</html>

解决方案 »

  1.   

    sorry
    --------------------
    <head>
    <public:component tagName="mydiv">
    <public:attach event="oncontentready" onevent="f_contentReady()" />
    <public:defaults viewLinkContent="true" />
    <METHOD NAME="alertMess"/>
    </public:component><script language="JScript">
    function f_contentReady()
    {
    defaults.viewLink = document;
    }function divClicked()
    {
    window.setTimeout("window.document.all."+element.id+".alertMess()", 1000);
    }function alertMess()
    {
    alert("This is a div.");
    }
    </script></head>
    <body>
    <div onclick='divClicked();'>my div</div>
    </body>
      

  2.   

    谢谢xjdawu(左右互搏)。你的方法必须要在html中设置mydiv的id属性,才能正确运行,不知道有没有更好的或者说更官方的解决方法存在??
      

  3.   

    不设置id
    --------------------------
    function divClicked()
    {
      window.setTimeout("window.document.all."+element.uniqueID+".alertMess()", 1000);
    }
      

  4.   

    uniqueID果然可以,谢谢xjdawu(左右互搏),佩服佩服。再顶一下,不知道还有没有别的方法实现,过几天再结帖我们写js的时候总有一种隔靴搔痒的感觉,客户端js写的过于复杂还是不可取啊。