One does not simply redirect using jQuery

jQuery is not necessary, and window.location.replace(...) will best simulate an HTTP redirect.

window.location.replace(...) is better than using window.location.href, because replace() does not keep the originating page in the session history, meaning the user won't get stuck in a never-ending back-button fiasco.

If you want to simulate someone clicking on a link, use location.href

If you want to simulate an HTTP redirect, use location.replace

For example:

// similar behavior as an HTTP redirect
window.location.replace("https://stackoverflow.com");

// similar behavior as clicking on a link
window.location.href = "https://stackoverflow.com";
Answer from Ryan McGeary on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-redirect-to-another-webpage-using-javascript
How to Redirect to Another Webpage using JavaScript? - GeeksforGeeks
July 11, 2025 - To redirect to a relative URL in JavaScript, you could use window.location.href. It is a property in JavaScript that represents the complete URL of the current page.
🌐
TutorialsPoint
tutorialspoint.com › javascript › javascript_page_redirect.htm
JavaScript - Page Redirection
You have built-up various pages based on browser versions or their names or may be based on different countries, then instead of using your server-side page redirection, you can use client-side page redirection to land your users on the appropriate page.
🌐
CoreUI
coreui.io › blog › how-to-redirect-to-a-new-url-using-javascript-redirect
How to Redirect to a New URL Using JavaScript Redirect Techniques · CoreUI
April 7, 2025 - Server-side redirects (HTTP Redirect): Recommended for permanent redirects (301) or temporary redirects (302). They are typically faster and better for SEO, as they clearly communicate the new URL to search engines. JavaScript redirects: Useful for dynamic client-side interactions, like redirecting users after form submissions (e.g., successful login to a success page).
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-redirect-a-url
JavaScript Redirect a URL - GeeksforGeeks
July 11, 2025 - In Javascript, window.location function is used to redirect to a URL.
🌐
Semrush
semrush.com › blog › javascript redirect: how to redirect to a new url
JavaScript Redirect: How to Redirect to a New URL
August 7, 2023 - ... You’ll have to do this by going to each page and manually changing the link. A JavaScript redirect is a method that uses JavaScript to direct a browser from the current webpage to a different URL.
Find elsewhere
🌐
Conductor
conductor.com › home › academy › redirects › faq › javascript redirect
Javascript redirect: how to redirect to another URL? - Conductor
April 21, 2024 - A little bit of background information: a JavaScript redirect is a client-side redirect that instructs browsers to load another URL.
🌐
Love2Dev
love2dev.com › blog › ways-to-use-javascript-redirect-to-another-page
4 Ways JavaScript Can Redirect Or Navigate To A Url Or Refresh The Page 🔀
The window.location has multiple methods to help you refresh, reload and change the current page. You can use this techique from your JavaScript to trigger page updates.
🌐
Tizag
tizag.com › javascriptT › javascriptredirect.php
Javascript Tutorial - Redirect
Learn how to redirect to another web page using javascript with Tizag.com's Javascript Redirect lesson.
🌐
JavaScript Tutorial
javascripttutorial.net › home › javascript bom › javascript redirect
JavaScript Redirect to a New URL - JavaScript Tutorial
August 17, 2022 - The following script redirects to the about.html which is on the same level as the current page. location.href = 'about.html';Code language: JavaScript (javascript)
🌐
Chris Pietschmann
pietschsoft.com › post › 2024 › 03 › 22 › javascript-redirect-to-another-webpage-with-javascript-jquery
Javascript: Redirect to another webpage with Javascript and jQuery | Chris Pietschmann
March 22, 2024 - Alternatively, you may want to perform the redirect on page load, this can be performed using an event listener for the DOMContentLoaded event that is fired when the document has finished loading content in the browser. Although simply embedding the setting of window.location in a <script/> tag within the page will have the same end result.
🌐
Invezza Technologies
invezzatechnologies.com › blog › javascript-redirect
JavaScript Redirect (Immediate and Time Delay) - Invezza Technologies
October 4, 2023 - In conclusion, JavaScript provides two ways to redirect users to a new page: immediately when the page loads, and after a time delay. By setting the window.location property to the URL of the new page, the browser will navigate to that page.
🌐
Simplilearn
simplilearn.com › home › resources › software development › javascript tutorial: learn javascript from scratch › how to redirect to another webpage using javascript
How to Redirect to Another Webpage Using JavaScript | Simplilearn
January 26, 2025 - Know how to redirect the webpage to another using Javascript. Learn several methods like location.href, location.replace() & location.assign() to redirect. Read Now!
Address   5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
🌐
Tabnine
tabnine.com › home › how to redirect to a different url with javascript
How to Redirect to a Different URL with JavaScript - Tabnine
July 25, 2024 - The document is replaced by removing it from the browser’s history, disabling the Back button in the process. You will want to keep this last point in mind when deciding on the redirect method you choose. One quick tip – as the window object is implied in JavaScript, you can simply use location instead of window.location.
🌐
Nintex Community
community.nintex.com › home › forums › product forums › skuid nlx, sfx, & exp › redirect url in javascript
Redirect URL in JavaScript | Community
July 11, 2024 - //Redirect to New URL var URL = '../../' + newOrderId.Id; var win = window.open(URL, '_blank');``` ... Hi Luzie, I have never used curly brackets within my JS snippets. ... Hey Tami, here is some example Javascript code that may help you out.
🌐
Quackit
quackit.com › javascript › javascript_redirect.cfm
JavaScript Redirect
To create a JavaScript redirect, place the following code between the <head> tags of your HTML page (replacing the URL with the URL that you want to redirect to).
🌐
Stack Abuse
stackabuse.com › javascript-how-to-redirect-to-another-webpage
JavaScript: How to Redirect to Another Webpage
August 5, 2025 - In this tutorial, we'll take a look at examples, pros and cons of several approaches on how to redirect a user to another page or URL in JavaScript.
🌐
Sentry
sentry.io › sentry answers › javascript › redirect to another page using javascript
Redirect to Another Page Using JavaScript | Sentry
if (api.response.success) { // Redirect to success page window.location.replace("https://yourdomain.com/success"); } else { // Show API response error message } This solution may not be ideal for something like a mailing list landing page, or any page where it’s important to preserve the “back” button’s behavior, as this will replace the user’s history. To preseve the “back” button behavior, rather use assign(). Capture and report JavaScript errors with window.onerror