user948557
user948557

Reputation: 43

js setting default url after using history.pushstate

I have a problem. How can i remove from url "content" added by history.pushState? For example i have a this url:

site.com

Ok, now i update this url to this:

site.com/site/subsite

How i can restore default url (site.com).

I try history.pushState("",document.title,document.location.pathname) but,

document.location.pathname is "site.com/site/subsite"

and i return to start point :(

Upvotes: 3

Views: 2406

Answers (1)

Nik Sumeiko
Nik Sumeiko

Reputation: 8723

history.pushState("", document.title, "/");

It will remove state completely from the domain url.

Upvotes: 5

Related Questions