How can I know whether the user clicked back/forward button in Chrome from within my Chrome Extension?
The only API that could give me any such info is the chrome.webNavigation.onCommitted
which in the case of when the back or forward button are clicked, sends a NavigationQualifier
containing the string 'forward_back'
. The problem here is that I'm not able to distinguish between the two buttons.
You could use the tabs
API's onUpdated
event if that's good enough for you.
Alternatively, you could use the HTML5 history API and register a window.onpopstate
handler. Do that from within a content script that runs before the page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With