相思资源网 Design By www.200059.com
//by xmg
<script>
function addEvent(obj,eventName,eventFunc){
if(obj.attachEvent) {
obj.attachEvent(eventName,eventFunc);
}else if(obj.addEventListener){
eventName = eventName.toString().replace(/on(.*)/i,'$1');
obj.addEventListener(eventName,eventFunc,true);
}
}
function delEvent(obj,eventName,eventFunc){
if(obj.detachEvent)
obj.detachEvent(eventName,eventFunc)
else if(obj.removeEventListener){
eventName = eventName.toString().replace(/on(.*)/i,'$1');
obj.removeEventListener(eventName,eventFunc,true);
}
}
</script>
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<button onclick=addEvent(document,"onclick",test1)>add1</button><br>
<button onclick=delEvent(document,"onclick",test1)>del1</button><br>
<button onclick=addEvent(document,"onclick",test2)>add2</button><br>
<button onclick=delEvent(document,"onclick",test2)>del2</button><br>
<script>
function test1(){
alert("test1")
}
function test2(){
alert("test2")
}
document.onclick=function(){
alert(1)
}
</script>
</BODY>
</HTML>
<script>
function addEvent(obj,eventName,eventFunc){
if(obj.attachEvent) {
obj.attachEvent(eventName,eventFunc);
}else if(obj.addEventListener){
eventName = eventName.toString().replace(/on(.*)/i,'$1');
obj.addEventListener(eventName,eventFunc,true);
}
}
function delEvent(obj,eventName,eventFunc){
if(obj.detachEvent)
obj.detachEvent(eventName,eventFunc)
else if(obj.removeEventListener){
eventName = eventName.toString().replace(/on(.*)/i,'$1');
obj.removeEventListener(eventName,eventFunc,true);
}
}
</script>
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<button onclick=addEvent(document,"onclick",test1)>add1</button><br>
<button onclick=delEvent(document,"onclick",test1)>del1</button><br>
<button onclick=addEvent(document,"onclick",test2)>add2</button><br>
<button onclick=delEvent(document,"onclick",test2)>del2</button><br>
<script>
function test1(){
alert("test1")
}
function test2(){
alert("test2")
}
document.onclick=function(){
alert(1)
}
</script>
</BODY>
</HTML>
相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com
暂无javascript之卸载鼠标事件的代码的评论...