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
汪杰 阅读(324)
评论(1) 编辑 收藏 引用 所属分类:
javascript