js判断浏览器之事件绑定

if(document.all){ //ie
    document.getElementById("div").attachEvent('onlick',function(){
    alert("");
     })
}else{//w3c
   document.getElementById("div").addEventListener('click',function(){
    alert("");
})
}

}

 

posted @ 2017-06-26 10:28  riyyao92  阅读(251)  评论(0)    收藏  举报