I want to make a script that disables hyperlinks and instead fires a function when one is clicked.
<a href="http://google.com"></a>
should work as
<a onclick="talk('http://google.com)'></a>
Is there a way to know when the wants to redirect and instead run “talk()” or display an alert window?
This solution uses (DOM Level 0) event handling instead of touching the href directly.
Edit: The benefit of this approach is it’s much simpler to put the href back when you want to. Given an anchor
tAnchor, you merely need to unset the onclick attribute: