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)

5
  • i think this can help you stackoverflow.com/questions/2161906/… Commented Mar 24, 2013 at 12:14
  • stackoverflow.com/questions/8212845/… Commented Mar 24, 2013 at 12:15
  • 1
    Could you elaborate on what you're trying to do? Maybe there's a better way. Commented Mar 24, 2013 at 12:15
  • hashchange only detect hash changes, i want to detect a full url change (maybe to another domain for example) Commented Mar 24, 2013 at 12:16
  • i don't its possible to detect the url change in tabs moreover its a security/privacy threat to detect/get/store the user's browsing activity, you can only access the URL of the current tab by using methods to get query string !! Commented Mar 24, 2013 at 12:17

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.