0

I'm removing the hash value with parent.location.hash = '' but that instantly makes the browser jump to the top of the page - can I just remove the #!ajax-url-part from the browser without making it jump to the top of the page?

Thank you.

Xeen
  • 6,755
  • 14
  • 53
  • 106

2 Answers2

2

As OP wants, I put my comment in an answer because is a valid answer:

You can read this blog:

http://spoiledmilk.com/blog/html5-changing-the-browser-url-without-refreshing-page/

The trick is as easy as this:

  window.history.pushState(“object or string”, “Title”, “/new-url”);

Good luck!

Marcos Pérez Gude
  • 21,096
  • 4
  • 36
  • 67
0

window.location.href.substr(0, window.location.href.indexOf('#'))

or

window.location.href.split('#')[0]

Kaushik Maheta
  • 1,645
  • 1
  • 16
  • 27