0

I want update the url without page reloading or refresh. I've tried with below logic but no luck. Every time page is loading. Any help please?

  var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?k=' + vm.name + '&l=' + vm.sid;
            //var newurl = $location.protocol() + "//" + $location.host() + $location.path() + '?k=' + vm.name + '&l=' + vm.sid
            //window.history.pushState({ path: newurl }, '', newurl);
            //window.history.replaceState(null, null, newurl);
            //window.location.hash = 'k=' + vm.name + '&l=' + vm.sid
            //document.location = newurl;
user3194721
  • 765
  • 4
  • 14
  • 47
  • 1
    Possible duplicate of [Updating address bar with new URL without hash or reloading the page](http://stackoverflow.com/questions/3338642/updating-address-bar-with-new-url-without-hash-or-reloading-the-page) – Heretic Monkey Sep 06 '16 at 21:49
  • Are you just trying to re-write the URL without loading? Or going to a new page? – IronWilliamCash Sep 06 '16 at 21:49
  • Hi Mike, they are suggesting window.history.pushState("object or string", "Title", "/new-url"); but I'm already using window.history.pushState({ path: newurl }, '', newurl); Page is refresting if I'm using this logic. – user3194721 Sep 06 '16 at 22:47
  • Hi William, I'm rewriting the URL in same page. – user3194721 Sep 06 '16 at 22:47

0 Answers0