<script type="text/javascript">
function addEvent(obj,ev,fn){
if(window.addEventListener){
obj.addEventListener(ev,fn,false);
}else{
obj.attachEvent("on"+ev,fn);
}
}
addEvent(document,"click",function(){
alert(‘a‘);
});
addEvent(document,"click",function(){
alert(‘b‘);
});
</script>
Javascript:兼容ie的事件绑定函数
时间: 2024-10-09 23:45:43