How to call a function on URL change in javascript