删除句柄报错了,请大家帮帮忙呗
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<div class="box">
<input type="button" id="bnt1" onclick="test()" value="按钮1" />
<input type="button" id="bnt2" value="按钮2"/>
<input type="button" id="bnt3" value="按钮3" />
<input type="button" id="bnt4" value="按钮4" />
<input type="button" id="bnt5" value="按钮5" />
</div>
<script type="text/javascript">
var bnt1=document.getElementById("bnt1");
var bnt2=document.getElementById("bnt2");
var bnt3=document.getElementById("bnt3");
var bnt4=document.getElementById("bnt4");
var bnt5=document.getElementById("bnt5");
/*DOM0*/
function test()
{
alert("搞出的内容11!");
}
/*DOM0结束*/
/* bnt2.onclick=function()
{
alert("搞出内容2!");
}
bnt3.addEventListener("click",test,false);
bnt3.addEventListener("click",function(){alert(this.value);},false);
bnt4.addEventListener("click",function(){alert(this.value);},false);*/
/*DOM2结束*/
//跨浏览器事件
var eventUtil=
{//添加句柄
addHandler:function(element,type,handler)
{
//DOM2开始
if(element.addEventListener)
{
element.addEventListener(type,handler,false);
}
//DOM2结束
//DOM0开始
else if(element.attachEvent)
{
element.attachEvent('on'+type,handler);
}
//DOM0结束
else
{
element['on'+type]=handler;
}
},
//删除句柄
removeHandler:function(type,handler,false)
{
//DOM2开始
if(element.removeEventListener)
{
element.removeEventListener(type,handler,false);
}
//DOM2结束
//DOM0开始
else if(element.detachEvent)
{
element.detachEvent('on'+type,handler);
}
//DOM0结束
else
{
element['on'+type]=null;
}
}
}
eventUtil.addHandler(btn5,'click',test);
eventUtil.removeHandler(btn5,'click',test);
</script>
</body>
</html>
删除句柄报错了是怎么回事大家帮我看看呗!