mercredi 13 juillet 2016

Check if the link results in reloading the page

I develope a chrome extension; with a content script I inject some code in the page. What I want is an event that triggers if the current tab is going to update. I tried to catch the click event of an a-element and it does work in somehow 80% of all cases. I already check if it's an anchor, but there are still many links which don't reload the page or forward to another.

$('a', document).click(function (e) {
// ...
});

So, what I want is described in the following three steps:

  1. Event: the page is going to reload

  2. prevent it from reloading, execute some code

  3. trigger reloading the page afterwards

Aucun commentaire:

Enregistrer un commentaire