addHandler和removeHandler在DW CS6里是不是不能用啊,在CS6里不显示,就好像没定义的变量似的
<script>
var btn6 = document.getElementById('btn6');
function shouMas(){
alert('这是跨浏览器事件')
}
var eventUtil = {
//添加句柄
addHandler:function(element/*给谁添加*/,type/*添加类型*/,handler/*句柄,触发了什么操作*/){
if(element.addEventListener){
element.addEventListener(type,handler,false);
}else if(element.attachEventer){
element.attachEventer('on' + type,handler);
}else{
element['on' + type] = handler//element.onclick === element['onclick']
}
//删除句柄
removeHandler:function(element,type,handler){
if(element.removeEventListener){
element.removeEventListener(type,handler,false);
}else if(element.detachEventer){
element.detacheEventer('on' + type,handler);
}else{
element['on' + type] = null;//element.onclick === element['onclick']
}
}
}
}
eventUtil.addHandler(btn6,'click',showMas);
</script>