how to redirect a URL in JavaScript

Here’s how you redirect a URL in JavaScript. Just set the value of window.location.replace to the URL you want.

<script type=“text/javascript”>
window.location.href = “"

When redirecting, window.location.replace is preferred over window.location.href.

// similar behavior as an HTTP redirect

// similar behavior as clicking on a link window.location.href = “";