谁能告诉我为啥没反应呢,加断点后不知道怎么看对错,我也是醉了,--SOS
<!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 id="box">
<input type="button" value="submit1" id="btn1">
<input type="button" value="submit2" id="btn2">
</div>
<script>
var btn1=document.getElementById('btn1');
var btn2=document.getElementById('btn2');
function showmess(){
alert('you are my message');
}
var eventUtil={
addHandler:function(element,type,handler){
//DOM2 处理程序的方法
if(element.addEventListener){
element.addEventListener(type,handler,false);
}
//IE 处理程序方法
else if(element.attachEvent){
element.attachEvent('on'+type,handler);
}
//DOM0处理事件程序判断
else{
element['on'+type]=handler;//触发handler操作
}
}
}
//删除句柄
removeHandler:function(element,type,handler){
if(element.removeEventListener){
element.removeEventListener(type,handler,false);
}
//IE事件处理程序
else if(element.detachEvent){
element.detachEvent('on'+type,handler);
}
else{
element['on'+type]=null;
}
}
eventUtil.addHandler(btn2,'click',showmess);
</script>
</body>
</html>