0

I have a Chrome extension with a content script that must be injected when the url matches the rule. the thing is, if I refresh the page, it's working, but if I navigate to the url (it does match the pattern) then the event is not triggered.

Any idea why?

Edit: Take into account that it's based on a web app and I've tried using the webNavigation event and still doesn't work.

Edit: Ok, so a working solution (in Chrome at least) is to use the onHistoryStateUpdated event handler.

Brian Tompsett - 汤莱恩
  • 5,438
  • 68
  • 55
  • 126

1 Answers1

0

Possibly due to the cache saved in your Browser. If you hard refresh it, then it will run the whole script again. You can use the following code:

$(window).bind("load", function() {
   // code here
});

You can also try this function:

window.onpageshow()
Rajat Jain
  • 1,247
  • 2
  • 15
  • 28