I'm writing a plugin that needs to operate on arbitrary sites, and needs to prevent the url from changing.
Using e.preventDefault
works to prevent normal anchor links from changing the url.
However any active javascript event handlers on site can still update the url. Unless I'm severely mistaken using e.stopImmediatePropagation
doesn't solve this issue, since there's no way to guarantee that 'my' event handler containing e.stopImmediatePropagation
is the first event handler being run. (Again, because I don't control the site)
Now I can prevent all clicks from happening by the 'hack' of placing a transparent element under the mouse on mousedown and remove it again on mouseup.
However, that prevents any other click-interaction that doesn't result in a url change. If at all possible I'd like to keep these interactions enabled.
Any solutions that help me get out of this conundrum?