为何我的不能运行啊?文件的路径都是对的按照啊老师的步骤来的啊 跳不出alert
文件index.html
<!DOCTYPE html>
<html>
<head>
<title>事件流</title>
<meta charset="utf-8">
<script src="js/event.js"></script>
<script src="js/script.js"></script>
</head>
<body>
<div id="box">
<input type="button" value="按钮1" id="btn1" onclick="showMes()">
<input type="button" value="按钮2" id="btn2">
<input type="button" value="按钮3" id="btn3">
<a href="event.html" id="go">跳转</a>
</div>
</body>
</html>
js文件event.js
var eventUtil={
addHandler:function (element,type,handler) {
if (element.addEventListener){
element.addEventListener(type,handler,false);
}else if (element.attachEvent){
element.attachEvent("on"+type,handler);
}else{
element["on"+type]=handler;
}
},
removeHandler:function (element,type,handler) {
if (element.removeEventListener){
element.removeEventListener(type,handler,false);
}else if (element.detachEvent){
element.detachEvent("on"+type,handler);
}else{
element["on"+type]=null;
}
},
getEvent:function (event) {
return event?event:window.event;
},
getType:function (event) {
return event.type;
},
getElement:function (event) {
return event.target||event.srcElement;
},
preeventDefault:function (event) {
if(event.peventDefault){
event.peventDefault();
}else{
event.returnValue=false;
}
},
stopPropagation:function (event) {
if(event.stopPropagation){
event.stopPropagation();
}else{
event.cancelBubble=true;
}
}
}
js文件script.js
window.onload=function () {
var go=document.getElementById("go"),
box=document.getElementById("box");
eventUtil.addHandler(box,"cllick",function(){
alert("我是整个父盒子!");
})
}