javascriptjqueryurlhashchange

Detect specific part of url change


I am having problem of detecting change on my url , problem is that , that i use same first part of url after # ,example

mySite.com/masterPage.html#pageView=employee&employeeCode=10

If i listen for changes with window.onhashchange = function(); ,it doesnt detect changes if i just change url to

 mySite.com/masterPage.html#pageView=student

Because hash has stayed same as before , any ideas how to detect change of pageView on url change


Solution

  • Do it with jQuery, works fine for me.

    $(window).on("hashchange", function(){
        alert('change');
    });
    

    Tested whith mySite.fr/#toto and mySite.fr/#tototata Event was fired when anchor changed.