Skip to content

How to Redirect User to Another Webpage with JavaScript

Advertisement

This tutorial will help you to redirect a webpage to another webpage using JavaScript. Here are 3 examples of redirecting webpage to another with JavaScript.

Example 1:

We can redirect user to other page using window.location.replace in JavaScript. window.location.replace has pretty similar to an HTTP redirect.

Example 2:

It is better to use window.location.href in place of window.location.replace, because replace() function does not put the originating page in the session history.

Example 3:

We can also simply redirect to any internal website page using window.location.

Rahul

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top