Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to alter address bar URL while I'm in a different website?

Let’s say I’m on a https://www.example.com. Can I alter address bar URL to display https://www.google.com while I’m in https://www.example.com website using JavaScript?

ex:

I’m on https://www.example.com website, But what if I wanna display different URL like http://www.google.com in the address bar? Is it possible?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Just asking based on learning purpose about the information security.

>Solution :

No, that would be a security risk, if any website could make it appear to the user to actually be on any other website. Phishing would be a whole lot easier if that was permitted.

The best you can do is history.pushState (or .replaceState), which has the reasonable restriction that:

The new URL can be any URL in the same origin as the current URL.

Or, of course, you could actually redirect to the other website by assigning to location.href.

It might be possible to write a browser extension that fiddles with the internals of the browser so that it displays your arbitrary desired text instead of the actual current page, but such a thing would have to be deliberately installed by the user.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading