Coder Perfect

In JavaScript, how to cause the browser to travel to a URL [duplicate]


What is the best (proper, current, cross-browser, and safe) approach to use JavaScript to navigate a web browser to a URL of your choice?

Asked by jjujuma

Solution #1

This is compatible with all browsers:

window.location.href = '...';

If you wish to modify the page without it affecting your browser’s history, follow these steps:


Answered by Paolo Bergantino

Solution #2

Try these:

For more see this link: other ways to reload the page with JavaScript

Answered by tilak

Solution #3

This appears to be the proper method window.location.assign(“”);

Answered by Bogdan

Post is based on