Using JavaScript to Redirect to a New Page

Using JavaScript to Redirect to a New Page

When a person comes to a page, it is actually possible to redirect them to a new page. Because someone might have bookmarked the page, you can use this when you want to remove a page from your site so that you can avoid sending the person to a 404 error page.

window.location = ""; 

This page will be gone in a blink of the eye because of the script redirect!

Looking at the code, you’ll see that the window location is changed to You could change this to any other site as well. The one downfall with this redirect is that if scripting is turned off, it won’t work.


About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist