Monday, May 20, 2024
24
rated 0 times [  28] [ 4]  / answers: 1 / hits: 30279  / 14 Years ago, mon, february 7, 2011, 12:00:00
var links = document.body.querySelectorAll(p.sourcelinks a.individual_source_link);
for(var i=0;i<links.length;i++)
{
links[i].onclick = null;
}


Is my current code, however it doesn't remove the onclick events. I have no idea what they will be since this is a greasemonkey script.


More From » greasemonkey

 Answers
5

Your code only deals with events added by element.onclick case. What about events added with addEventListener (for standards compliant browsers) and attachEvent (for IE)?



You need to use removeEventListener and detachEvent to remove events as well as setting .onclick to null. Then all your bases will be covered.


[#93865] Friday, February 4, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cristinadomoniquel

Total Points: 320
Total Questions: 94
Total Answers: 94

Location: Moldova
Member since Sat, Aug 6, 2022
2 Years ago
cristinadomoniquel questions
Wed, Apr 7, 21, 00:00, 3 Years ago
Tue, Dec 1, 20, 00:00, 4 Years ago
Mon, Nov 23, 20, 00:00, 4 Years ago
Mon, Aug 17, 20, 00:00, 4 Years ago
;