There are three methods for redirecting to a new URL in JavaScript: Using window.location.href Using window.location.assign() Using window.location.replace() Method 1: Using window.location.href This is the most straightforward method. It's similar to clicking a link. Syntax window.location.href = "newURL"; Example
Advertisement