Francesco Frassinelli
Francesco Frassinelli

Reputation: 3375

Execute a function after the url changes in jQuery

I would like to know if it's possible to use .unload(...) or a similar function in Javascript or jQuery in order to execute an action after the user changes or reload the page.

In my specific case, I've done a bookmarklet which creates a div element on the page and I want to keep it during my navigation, without executing another time the Javascript code.

I thought to solve it using JS/jQuery because I would not depend from my browser. If it's not possible, how can I achieve a similar result?

Upvotes: 0

Views: 972

Answers (1)

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114347

A URL change stops all current JavaScript execution.

You may want to look into using a URL HASH to maintain state.

Upvotes: 1

Related Questions