I want to add a listener to "before URL change" event, with access to the old URL. window.onbeforeunload
does not fire if the page does not reload (AJAX driven pages).
This happens on YouTube video pages, when you click on another video in the right navigation column, for example.
I have read this post, which polls window.location
. But this does not capture the old URL.
This is for a Chrome extension. I'm looking for a way to detect before URL change in javascript.