1

Is it possible to replace the origin of the URL without reloading the page? Say I am at www.example.com, how can I change the URL to be www.foo.com or whatever without reloading the page? I tried using pushState() and replaceState() to no avail. I get an error saying: Failed to execute 'pushState' on 'History': A history state object with URL 'foo.com:4041' cannot be created in a document with origin 'http://example.com:4041' and URL 'http://foo.com:4041/'.

For your information. the two URLS are ones which I generated with my /etc/hosts file, they simply pass to an express server at localhost:4041.

Thanks

Tino
  • 41
  • 3
  • @Mamun the dupe target is not correct for this question, there they are not trying to break SOP. – Kaiido Dec 30 '18 at 06:52
  • This is a different question. I am not trying to simply append onto a URL like adding /foo to bar.com. I am looking to change bar.com completely to another URL without a page refresh. – Tino Dec 30 '18 at 06:57
  • A better dupe target would be https://stackoverflow.com/questions/28461691/change-domain-name-in-url-bar-with-javascript but it has no upvoted nor accepted answer... On a phone rn so there might be others valids. And @Tino, this can't be done. Imagine I manage to launch a popup which behaves like your bank's website, and even has your bank's url in the address bar? I'd become pretty rich pretty far (or in prison) – Kaiido Dec 30 '18 at 07:02
  • @Kaiido Yeah, I ended up reading that elsewhere. That makes a lot of sense. I was curious because I am making a recaptcha harvester and need to be able to fake the URL. I was hoping of being able to do that without a page refresh but it's fine honestly. Thanks for the help! – Tino Dec 30 '18 at 07:16
  • Possible duplicate of [Html5 History Api - pushState from a domain to a subdomain](https://stackoverflow.com/questions/14807921/html5-history-api-pushstate-from-a-domain-to-a-subdomain) – marvinhagemeister Dec 30 '18 at 09:49

0 Answers0