Skip to content

How to Redirect User to Another Webpage with JavaScript

How To Redirect User to Another Webpage using JavaScript. How to Redirect user one page to another using JavaScript. Redirect user page using javascript.

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

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

Leave a Reply

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


Back to top