给div添加程序没有反应
<!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=gb2312" />
<title>无标题文档</title>
<script src="event.js"></script>
<script src="javascript.js"></script>
</head>
<body>
<div id="box">
<input type="button" id="btn1" value="按钮1"/>
<input type="button" id="btn2" value="按钮2"/>
<a href="http://www.baidu.com/" id="go" >跳转</a>
</div>
</body>
</html>
//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;
//return event=event||event=window.event;
}
getEventType:function(event){
return event.type;
}
getEventsrc:function(event){
return event.target || event.srcElement;
}
//阻止事件冒泡
stopBubble:function(event){
if(event.stopPropagation){
event.stopPropagation();
}
else{
event.cancelBubble=true;
}
}
//组织事件默认行为
stopaction:function(event){
if(event.preventDefault){
event.paeventDefault();
}
else{
event.returnValue=false;
}
}
}
// JavaScript Document
window.onload=function(){
var go=document.getElementById('go'),
box=document.getElementById('box');
eventUtil.addHandler(box,'click',function(){
alert('我是一个复合纸');
}
);
}