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,955
  • 16
  • 60
  • 111

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,869
  • 4
  • 38
  • 69
0

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

or

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

Kaushik Maheta
  • 1,741
  • 1
  • 18
  • 27