I am trying to write a Cross-Browser script that detects when a link is clicked on a page (text link, image, or on the other hand) so that I can display a message or ad (e.g. interstitial) and then direct the visitor to the destination destination URL.
The script should work from third-party sites (where the owner sets the script tags on his site).
How can I accomplish this using javascript?
Am I using an event listener? Am I iterating over all link objects? Or something else?
My JavaScript skills are new / intermediate, so detailed examples / explanations are much appreciated.
I started using the event listener here, but so far I find ALL clicks on the page: addEventListener Code Snippet Translation and use to detect multiple browsers
I will consider an alternative to jQuery, but I just donβt know how it will work on a third-party site if there is no jQuery library on this site.
Thanks to everyone.
javascript jquery cross-browser event-listener
C king
source share