Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to intercept window.location change

I need a way to attach some pre-processing to each assignment of the window.location. Is there a way to do this. I basically need to serialize some info, that will be used in the new location.

like image 813
epitka Avatar asked Jan 15 '10 16:01

epitka


People also ask

What does Window location replace do?

Window location. The replace() method replaces the current document with a new one.

What is Windows location return?

Window Location Href href property returns the URL of the current page.


1 Answers

You can use the beforeunload event to trigger your code to run prior to navigation... If you need something more specific (e.g., only navigations initiated in your code), then I recommend that you factor out code changing window.location into a separate function, and add a hook for your custom logic.

like image 86
Hackles Avatar answered Sep 24 '22 06:09

Hackles