snippetjavascriptCritical
How to get the browser to navigate to URL in JavaScript
Viewed 0 times
browserhowurlthenavigatejavascriptget
Problem
What is the best (correct, modern, cross-browser, safe) way to get a web browser to navigate to a URL of your choice using JavaScript?
Solution
This works in all browsers:
If you wanted to change the page without it reflecting in the browser back history, you can do:
window.location.href = '...';If you wanted to change the page without it reflecting in the browser back history, you can do:
window.location.replace('...');Code Snippets
window.location.href = '...';window.location.replace('...');Context
Stack Overflow Q#1226714, score: 1973
Revisions (0)
No revisions yet.