如何禁用页面上的所有onclick事件 [英] How do I disable all the onclick events on a page

查看:106
本文介绍了如何禁用页面上的所有onclick事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好希望禁用页面上的所有onclick事件 我写这个:

Hi want to disable all onclick events on a page i write this:

window.onclick = anyfunction;
document.onclick=anyfunction;
function anyfunction() {};

可以,但是如果页面包含此代码

That's work but if page contain this code

$("body").click(function () { 
  anyfunctions();
});

它将运行. 甚至我加

document.body.onclick

document.body.onclick

jQuery代码再次运行. 我想在不使用jquery库的情况下使用javascript禁用所有onclick函数(java脚本和jquery和...)

Jquery code runs again. I want to disable all onclick functions (java script and jquery and ... ) with javascript without using jquery library

目标是阻止弹出窗口 谢谢

Target is to block popup windows Thanks

推荐答案

$("*").unbind("click"); // Removes all click handlers added by javascript from every element
$("[onclick]").removeAttr("onclick"); // Finds all elements with an 'onclick' attribute, and removes that attribute

这篇关于如何禁用页面上的所有onclick事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆