How to determine which script is preventing link clicks to be processed?

Viewed 35

I took over the development responsibility of a PHP web application using a plethora of JS libraries and JQuery plugins.

Click event on any page using the default template is apparently trapped by some script which then

  • always prevents selection of any text on the page (the opposite behavior is a requirement)
  • prevents sidebar links (with href="#") from being triggered via the associated js/jQuery click function (for example: $('a.someclass').click(function(e) { ... ).

I have searched the entire project for any files which might be containing "preventDefault()" but couldn't find anything?

What should I do to find out which one of the scripts is causing the issue?

Is the only way of finding out disabling all scripts and then activating one by one as I test the functionality along the way (which, in my case take weeks, therefore hoping to be advised of a shorter way)?

1 Answers

I think Chrome developer tools can help you to figure out, which click listener is the right you need, so open your page into the Google Chrome Browser, then right click (for Windows) or double tap in the touchpad (Mac Os), then:

  1. Select Inspect option in the context menu
  2. It will open a window with the developer tools, then select the Sources tab
  3. Then in the right panel you will see some accordion panels go to the Event Listeners Breakpoints
  4. Go open the Mouse panel and mark click and mousedown events
  5. Refresh the page and start clicking in the items to figure out which event you need, you will notice that a light silver overlay layer will appear in the site, so you can go to next listener until you find what you looking for.

you can find more information at the Google Chrome Developer Tools

Related