0

I'm implementing a browser plugin.
I want to detect the event for document url changed to another url other than the current.
Something like this [BTW, that's pseudo code]:

$(window).bind('documenturlchange', function() {
    alert("page document url has been changed");
});

How to achieve this functionality ?

BTW, hashchange only detects "hash parts" changed in url, but it doesn't detect a whole link change (maybe to another domain for example)

Ashraf Bashir
  • 9,686
  • 15
  • 57
  • 82

1 Answers1

0

You can make use of the window DOM objects hashchange event to detect for change in URLs. For instance, lets say the current URL is http://yourhost.com and the new url is http://yourhost.com#changed, in this case onhashchange event will be triggered.

Reference: HashChange

jjk_charles
  • 1,250
  • 11
  • 23
  • 3
    hashchange only detects "hash parts" changed in url, but it doesn't detect a whole link change (maybe to another domain for example). for example if current url is www.google.com and I moved to www.yahoo.com, this event will not be triggered – Ashraf Bashir Mar 24 '13 at 12:34