Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
35
rated 0 times [  40] [ 5]  / answers: 1 / hits: 51367  / 10 Years ago, thu, november 6, 2014, 12:00:00

I would like to trigger some Javascript function when window.location.href link changes. Is it possible?



Something like this:



$(window.location.href).on('change', function(){
doSomething();
});

More From » jquery

 Answers
5

You said 'something like', given the example code you're probably looking for the onbeforeunload event handler.



From the Mozilla docs:



window.onbeforeunload = function(e) {
return 'Dialog text here.';
};

[#68885] Tuesday, November 4, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
aidan

Total Points: 72
Total Questions: 95
Total Answers: 121

Location: Uzbekistan
Member since Sat, Feb 27, 2021
3 Years ago
aidan questions
Mon, Oct 11, 21, 00:00, 3 Years ago
Wed, Sep 29, 21, 00:00, 3 Years ago
Sun, Sep 5, 21, 00:00, 3 Years ago
Thu, Jan 16, 20, 00:00, 4 Years ago
;