1

I have a chrome extension that injects a button to allow user capture current page data. However, one of websites that we support is running on AngularJs. When the page navigates to different page, there is no server reload. Is there a way to listen to the client event when page changes so our chrome extension can refresh with current page's data?

angelokh
  • 9,426
  • 9
  • 69
  • 139
  • That site is probably a single-page app and uses AngularJS route events, see [this](http://stackoverflow.com/q/14809686/3959875) and [other similar questions](http://stackoverflow.com/search?q=angularjs+route++event). – wOxxOm Jul 28 '15 at 06:09
  • this happens on most good pages not just with angular. detect url changes. – Zig Mandel Jul 28 '15 at 12:44
  • @wOxxOm We don't own the angular page. How can we do this from Chrome extension to watch the page change event? – angelokh Jul 28 '15 at 15:55
  • @ZigMandel Can you elaborate more? – angelokh Jul 28 '15 at 15:56
  • 1
    Try the universal way: [chrome.webNavigation.onHistoryStateUpdated.addListener](https://developer.chrome.com/extensions/webNavigation#event-onHistoryStateUpdated) or in your content script: `document.addEventListener("pageshow", ...)` (also "pagehide" and "popstate") – wOxxOm Jul 28 '15 at 15:57
  • @wOxxOm Can you put this to answer so I can approve it? – angelokh Jul 28 '15 at 18:02

1 Answers1

4

Use the universal methods to detect such url changes:

wOxxOm
  • 65,848
  • 11
  • 132
  • 136