user2013881
user2013881

Reputation: 1

make a script after document.location.href

I want to add an alert("some text") message after document.location.href or some kind of related code.

ex:

document.location.href = "http://www.msn.com";
windows.alert("You are now at msn.com");

By the moment I use document.location.href I automatically switch site so the rest of the code isn't being done. So I would like to know if there is an other way to switch site on the same page/ not on the same page and after that put my custom code and it will be executed accordingly?

Upvotes: 0

Views: 1393

Answers (1)

What have you tried
What have you tried

Reputation: 11148

Use the haschange event:

$(window).on('hashchange', function() {
  // your code here
});

See this post

Upvotes: 1

Related Questions