likonen
likonen

Reputation: 1

How do I change part of the URL without reloading the page?

Let's say I have this url: https://meta.stackexchange.com/users/login?returnurl=123456

How do I replace the 123456 part without reloading the page?

I found the replacestate option but from what I understand it replaces the whole URL, not just the part of the URL that I want.

Upvotes: 0

Views: 60

Answers (1)

window.history.pushState({}, 'title' , window.location.href.replace('123456','not123456'));

Upvotes: 3

Related Questions