My website, as most websites today, uses the same template for most of its pages and I am building a system that allows for ajax to load only page content without reloading the whole template. For the purpose I'm looking for a method that fires before the browser is redirected to another page. Something like onbeforeunload
but I also need to know the location of the redirect, is there such a thing?
I need to catch link clicks, back button clicks, forward button clicks as well as manual redirects like window.location = url