代码错在哪里了 萌新求解
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>引用JS文件</title>
<script src="script.js"></script>
<script src="event.js"></script>
</head>
<body>
<div id='box'>
<input type="button" value="按钮2" id="btn2">
<input type="button" value="按钮3" id="btn3">
<a href="http://www.baidu.com" id="go">跳转</a>
</div>
</body>
</html>
window.onload=function(){
var go=document.getElementById('go');
var box=document.getElementById('box');
jianrong.add(box,'click',function(){
alert("怎么错的,求解?");
});
}
var jianrong={
add:function(element,type,handler){
if(jianrong.addEventListener){
jianrong.addEventListener(type,handler,false);
}else if(jianrong.attachEvent){
jianrong.attachEvent('on'+type,handler);
}else{
jianrong['on'+type]=handler;
}
},
remove:function(element,type,handler){
if(jianrong.removeEventListener){
jianrong.removeEventListener(type,handler,false);
}else if(jianrong.detachEvent){
jianrong.detachEvent('on'+type,handler);
}else{
jianrong['on'+type]=null;
}
},
getelement:function(event){
return event?event:window.event;
},
gettarget:function(event){
return event.target||event.srcElement;
},
stop:function(event){
if(event.stopPropagation){
event.stopPropagation();
}else{
event.cancelBubble=true;
}
},
prevent:function(event){
if(event.preventDefault){
event.preventDefault();
}else{
event.returnValue=false;
}
}
}