Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

window.onpopstate and window.onhashchange don't seem to be working in content script

52 views
Skip to first unread message

quaz...@gmail.com

unread,
Jul 21, 2016, 1:48:14 PM7/21/16
to
hello,

window.onpopstate and window.onhashchange don't seem to be working in content script

my permissions are:
"permissions": [
"tabs",
"notifications",
"storage",
"webNavigation",
"webRequest",
"webRequestBlocking"
],

Are they blocked or is there an alternative?

Thanks in advance.

lgr...@mozilla.com

unread,
Jul 21, 2016, 2:06:22 PM7/21/16
to
If you need to subscribe a callback from the content script,
have you already tried to register an event listener to the popstate and hashchange events using window.addEventListener (instead of using the onpopstate/onhashchange window properties)?

If you don't need a callback registered from a content script, the webNavigation API has specific events that can be used from the background page:

- webNavigation.onHistoryStateUpdated (https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/WebNavigation/onHistoryStateUpdated)
- webNavigation.onReferenceFragmentUpdated (https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/WebNavigation/onReferenceFragmentUpdated)

quaz...@gmail.com

unread,
Jul 21, 2016, 2:59:37 PM7/21/16
to
Yes, eventlisteners were tried with no response.

I tried your suggested links and got this:
chrome.webNavigation is undefined

same error for browser.webNavigation...

0 new messages