javascript 기본 click 이벤트를 어디선가 가로 채어 cancel(preventDefaut) 되었을 때, 이를 누가 가로챘는지 디버깅(debugging)하는 방법

experience

  • anchor태그의 href에 uri를 적어두었는데, 해당 uri로 페이지 이동이 안되는 이슈 발견...
​
어디선가 click이 취소된 것으로 보이나, 누가 막고 있는지 확인이 필요...
​
​
​
간단히 javascript의 Event 객체의 preventDefault prototype을 override해서 해결 가능..
​
var oldEPD = Event.prototype.preventDefault;
Event.prototype.preventDefault = function() {
debugger;
oldEPD.call(this);
};
​
​
from : https://stackoverflow.com/questions/20490931/how-to-find-what-is-causing-a-preventdefault-which-overrides-normal-click-behavior

댓글