asfman
android developer
posts - 90,  comments - 213,  trackbacks - 0

wsc文件:
<?XML version="1.0"?>
<component id="bvrscript">
<registration progid="Behaviorscript"/>
<implements type="Behavior">
   <attach event="onmouseover" handler="over"/>
   <attach event="onmouseout" handler="out"/>
   <attach event="onload" handler="ld" for="window"/>
   <layout>
   <![CDATA[
      <h1>This is the HTML to show in the element</h1>
   ]]>
   </layout>

</implements>
<public>
  <event name="customize" />
  <method name="test"/>
</public>
<script language="JScript">
<![CDATA[
function ld()
{
   document.body.innerHTML += "load successfully!";
}
var orColor,orBg;
function over(){
   orColor = style.color;
   style.color = "red";
   style.backgroundColor = "yellow";
}
function out(){
   style.color = orColor;
   style.backgroundColor = "";
}
function test(){
var oEvent = createEventObject();
oEvent.asfman="pass the expando prop";
fireEvent("customize",oEvent);
return 123;
}
]]>
</script>
</component>
htm文件:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>this is a test div</title>
</head>

<body>
<div id="test" style="behavior:url(behavior.wsc);border:1px solid red;width:200px;height:100px;line-height:100px;text-align:center;"></div>
<script>
var o = document.getElementById("test");
o.customize=function(){alert(event.asfman);};
alert(o.test());
</script>
</body>

</html>
新在学会了通过createEventObject创建事件实例传递属性给event,非常爽

posted on 2007-11-13 16:33 汪杰 阅读(314) 评论(1)  编辑 收藏 引用 所属分类: javascript

FeedBack:
# re: implements type=behavior的各种尝试
2007-11-13 16:34 | 汪杰
note:
在写一些html标签时需要<![CDATA[]]>包含起来,否者会出错  回复  更多评论
  
只有注册用户登录后才能发表评论。

<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

常用链接

留言簿(15)

随笔分类(1)

随笔档案(90)

文章分类(727)

文章档案(712)

相册

收藏夹

http://blog.csdn.net/prodigynonsense

友情链接

最新随笔

搜索

  •  

积分与排名

  • 积分 - 457557
  • 排名 - 6

最新随笔

最新评论

阅读排行榜

评论排行榜