|
|
|
|
|
by josephg
1054 days ago
|
|
> What I really want is to somehow tell the browser "if the current window URL is about to change via this anchor element, call this function instead". This is pretty doable using javascript - just register an onclick on the <a> tag and have your event handler cancel the default navigation behaviour. Your website will then continue to work great even if the user has javascript disabled. And all the built in browser behaviour (like the right click "link" menu, and ctrl+click) still works perfectly. That said, this is a pretty obscure "trick". It would certainly be nice if the DOM API made this easier to do. |
|
Also, .preventDefault() wasn't obscure in the jQuery era; if it's obscure now that's a sad commentary.