How do I redirect to another webpage?


Javascript Problem Overview

How can I redirect the user from one page to another using jQuery or pure JavaScript?

Javascript Solutions

Solution 1 - Javascript

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

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

Solution 2 - Javascript

WARNING: This answer has merely been provided as a possible solution; it is obviously not the best solution, as it requires jQuery. Instead, prefer the pure JavaScript solution.

$(location).prop('href', '')

Solution 3 - Javascript

Standard "vanilla" JavaScript way to redirect a page

window.location.href = 'newPage.html';

Or more simply: (since window is Global)

location.href = 'newPage.html';

> If you are here because you are losing HTTP_REFERER when redirecting, keep reading: > > (Otherwise ignore this last part)

The following section is for those using HTTP_REFERER as one of many security measures (although it isn't a great protective measure). If you're using Internet Explorer 8 or lower, these variables get lost when using any form of JavaScript page redirection (location.href, etc.).

Below we are going to implement an alternative for IE8 & lower so that we don't lose HTTP_REFERER. Otherwise, you can almost always simply use window.location.href.

Testing against HTTP_REFERER (URL pasting, session, etc.) can help tell whether a request is legitimate. (Note: there are also ways to work-around / spoof these referrers, as noted by droop's link in the comments)

Simple cross-browser testing solution (fallback to window.location.href for Internet Explorer 9+ and all other browsers)

Usage: redirect('anotherpage.aspx');

function redirect (url) {
    var ua        = navigator.userAgent.toLowerCase(),
        isIE      = ua.indexOf('msie') !== -1,
        version   = parseInt(ua.substr(4, 2), 10);

    // Internet Explorer 8 and lower
    if (isIE && version < 9) {
        var link = document.createElement('a');
        link.href = url;

    // All other browsers can use the standard window.location.href (they don't lose HTTP_REFERER like Internet Explorer 8 & lower does)
    else { 
        window.location.href = url; 

Solution 4 - Javascript

There are lots of ways of doing this.

// window.location
window.location.href = ''
document.location.href = '/path'

// window.history

// window.navigate; ONLY for old versions of Internet Explorer

// Probably no bueno
self.location = '';
top.location = '';

// jQuery
$(location).prop('href', '')

Solution 5 - Javascript

This works for every browser:

window.location.href = 'your_url';

Solution 6 - Javascript

It would help if you were a little more descriptive in what you are trying to do. If you are trying to generate paged data, there are some options in how you do this. You can generate separate links for each page that you want to be able to get directly to.

<a href='/path-to-page?page=1' class='pager-link'>1</a>
<a href='/path-to-page?page=2' class='pager-link'>2</a>
<span class='pager-link current-page'>3</a>

Note that the current page in the example is handled differently in the code and with CSS.

If you want the paged data to be changed via AJAX, this is where jQuery would come in. What you would do is add a click handler to each of the anchor tags corresponding to a different page. This click handler would invoke some jQuery code that goes and fetches the next page via AJAX and updates the table with the new data. The example below assumes that you have a web service that returns the new page data.

$(document).ready( function() {
    $('a.pager-link').click( function() {
        var page = $(this).attr('href').split(/\?/)[1];
            type: 'POST',
            url: '/path-to-service',
            data: page,
            success: function(content) {
               $('#myTable').html(content);  // replace
        return false; // to stop link

Solution 7 - Javascript

I also think that location.replace(URL) is the best way, but if you want to notify the search engines about your redirection (they don't analyze JavaScript code to see the redirection) you should add the rel="canonical" meta tag to your website.

Adding a noscript section with a HTML refresh meta tag in it, is also a good solution. I suggest you to use this [JavaScript redirection tool][1] to create redirections. It also has Internet Explorer support to pass the HTTP referrer.

Sample code without delay looks like this:

<!-- Place this snippet right after opening the head tag to make it work properly -->

<!-- This code is licensed under GNU GPL v3 -->
<!-- You are allowed to freely copy, distribute and use this code, but removing author credit is strictly prohibited -->
<!-- Generated by -->

<link rel="canonical" href=""/>
	<meta http-equiv="refresh" content="0;URL=">
<!--[if lt IE 9]><script type="text/javascript">var IE_fix=true;</script><![endif]-->
<script type="text/javascript">
	var url = "";
	if(typeof IE_fix != "undefined") // IE8 and lower fix to pass the http referer
		document.write("redirecting..."); // Don't remove this line or appendChild() will fail because it is called before document.onload to make the redirect as fast as possible. Nobody will see this text, it is only a tech fix.
		var referLink = document.createElement("a");
		referLink.href = url;
	else { window.location.replace(url); } // All other browsers
<!-- Credit goes to -->

[1]: "Client-side URL redirect code generator"

Solution 8 - Javascript

But if someone wants to redirect back to home page then he may use the following snippet.

window.location =

It would be helpful if you have three different environments as development, staging, and production.

You can explore this window or window.location object by just putting these words in Chrome Console or Firebug's Console.

Solution 9 - Javascript

JavaScript provides you many methods to retrieve and change the current URL which is displayed in browser's address bar. All these methods uses the Location object, which is a property of the Window object. You can create a new Location object that has the current URL as follows..

var currentLocation = window.location;

Basic Structure of a URL


enter image description here

  1. Protocol -- Specifies the protocol name be used to access the resource on the Internet. (HTTP (without SSL) or HTTPS (with SSL))

  2. hostname -- Host name specifies the host that owns the resource. For example, A server provides services using the name of the host.

  3. port -- A port number used to recognize a specific process to which an Internet or other network message is to be forwarded when it arrives at a server.

  4. pathname -- The path gives info about the specific resource within the host that the Web client wants to access. For example,

  5. query -- A query string follows the path component, and provides a string of information that the resource can utilize for some purpose (for example, as parameters for a search or as data to be processed).

  6. hash -- The anchor portion of a URL, includes the hash sign (#).

With these Location object properties you can access all of these URL components

  1. hash -Sets or returns the anchor portion of a URL.
  2. host -Sets or returns the hostname and port of a URL.
  3. hostname -Sets or returns the hostname of a URL.
  4. href -Sets or returns the entire URL.
  5. pathname -Sets or returns the path name of a URL.
  6. port -Sets or returns the port number the server uses for a URL.
  7. protocol -Sets or returns the protocol of a URL.
  8. search -Sets or returns the query portion of a URL

Now If you want to change a page or redirect the user to some other page you can use the href property of the Location object like this

You can use the href property of the Location object.

window.location.href = "";

Location Object also have these three methods

  1. assign() -- Loads a new document.
  2. reload() -- Reloads the current document.
  3. replace() -- Replaces the current document with a new one

You can use assign() and replace methods also to redirect to other pages like these



How assign() and replace() differs -- The difference between replace() method and assign() method(), is that replace() removes the URL of the current document from the document history, means it is not possible to use the "back" button to navigate back to the original document. So Use the assign() method if you want to load a new document, andwant to give the option to navigate back to the original document.

You can change the location object href property using jQuery also like this


And hence you can redirect the user to some other url.

Solution 10 - Javascript

Basically jQuery is just a JavaScript framework and for doing some of the things like redirection in this case, you can just use pure JavaScript, so in that case you have 3 options using vanilla JavaScript:

  1. Using location replace, this will replace the current history of the page, means that it is not possible to use the back button to go back to the original page.


  2. Using location assign, this will keep the history for you and with using back button, you can go back to the original page:


  3. I recommend using one of those previous ways, but this could be the third option using pure JavaScript:


You can also write a function in jQuery to handle it, but not recommended as it's only one line pure JavaScript function, also you can use all of above functions without window if you are already in the window scope, for example window.location.replace(""); could be location.replace("");

Also I show them all on the image below:

location.replace location.assign

Solution 11 - Javascript

Should just be able to set using window.location.


window.location = "";

Here is a past post on the subject:

Solution 12 - Javascript

Before I start, jQuery is a JavaScript library used for DOM manipulation. So you should not be using jQuery for a page redirect.

A quote from

> While jQuery might run without major issues in older browser versions, > we do not actively test jQuery in them and generally do not fix bugs > that may appear in them.

It was found here:

So jQuery is not an end-all and be-all solution for backwards compatibility.

The following solution using raw JavaScript works in all browsers and have been standard for a long time so you don't need any libraries for cross browser support.

This page will redirect to Google after 3000 milliseconds

<!DOCTYPE html>
        <p>You will be redirected to google shortly.</p>
                window.location.href=""; // The URL that will be redirected too.
            }, 3000); // The bigger the number the longer the delay.

Different options are as follows:

window.location.href="url"; // Simulates normal navigation to a new page
window.location.replace("url"); // Removes current URL from history and replaces it with a new URL
window.location.assign("url"); // Adds new URL to the history stack and redirects to the new URL

window.history.back(); // Simulates a back button click
window.history.go(-1); // Simulates a back button click
window.history.back(-1); // Simulates a back button click
window.navigate("page.html"); // Same as window.location="url"

When using replace, the back button will not go back to the redirect page, as if it was never in the history. If you want the user to be able to go back to the redirect page then use window.location.href or window.location.assign. If you do use an option that lets the user go back to the redirect page, remember that when you enter the redirect page it will redirect you back. So put that into consideration when picking an option for your redirect. Under conditions where the page is only redirecting when an action is done by the user then having the page in the back button history will be okay. But if the page auto redirects then you should use replace so that the user can use the back button without getting forced back to the page the redirect sends.

You can also use meta data to run a page redirect as followed.

META Refresh

<meta http-equiv="refresh" content="0;url=" />

META Location

<meta http-equiv="location" content="URL=" />

BASE Hijacking

<base href="" />

Many more methods to redirect your unsuspecting client to a page they may not wish to go can be found on this page (not one of them is reliant on jQuery):


I would also like to point out, people don't like to be randomly redirected. Only redirect people when absolutely needed. If you start redirecting people randomly they will never go to your site again.

The next paragraph is hypothetical:

You also may get reported as a malicious site. If that happens then when people click on a link to your site the users browser may warn them that your site is malicious. What may also happen is search engines may start dropping your rating if people are reporting a bad experience on your site.

Please review Google Webmaster Guidelines about redirects:

Here is a fun little page that kicks you out of the page.

<!DOCTYPE html>
        <title>Go Away</title>
        <h1>Go Away</h1>
            }, 3000);

If you combine the two page examples together you would have an infant loop of rerouting that will guarantee that your user will never want to use your site ever again.

Solution 13 - Javascript

var url = 'asdf.html';
window.location.href = url;

Solution 14 - Javascript

You can do that without jQuery as:

window.location = "";

And if you want only jQuery then you can do it like:


Solution 15 - Javascript

This works with jQuery:

$(window).attr("location", "");

Solution 16 - Javascript

# HTML Page Redirect Using jQuery/JavaScript Method

Try this example code:

function YourJavaScriptFunction()
    var i = $('#login').val();
    if (i == 'login')
        window.location = "Login.php";
        window.location = "Logout.php";

If you want to give a complete URL as window.location = "";.

Solution 17 - Javascript

Original question: "How to redirect using jQuery?", hence the answer implements jQuery >> Complimentary usage case.

To just redirect to a page with JavaScript:

window.location.href = "/contact/";

Or if you need a delay:

setTimeout(function () {
  window.location.href = "/contact/";
}, 2000);   // Time in milliseconds

jQuery allows you to select elements from a web page with ease. You can find anything you want on a page and then use jQuery to add special effects, react to user actions, or show and hide content inside or outside the element you have selected. All these tasks start with knowing how to select an element or an event.

    opacity: 0 //Put some CSS animation here
  }, 500);
    // OK, finished jQuery staff, let's go redirect
    window.location.href = "/contact/";

Imagine someone wrote a script/plugin with 10000 lines of code. With jQuery you can connect to this code with just a line or two.

Solution 18 - Javascript

You need to put this line in your code:


If you don't have jQuery, go with JavaScript:


Solution 19 - Javascript

So, the question is how to make a redirect page, and not how to redirect to a website?

You only need to use JavaScript for this. Here is some tiny code that will create a dynamic redirect page.

    var url ='url=')[1]; // Get the URL after ?url=
    if( url ) window.location.replace(url);

So say you just put this snippet into a redirect/index.html file on your website you can use it like so.


And if you go to that link it will automatically redirect you to

>Link to Documentation

And that's how you make a Simple redirect page with JavaScript


There is also one thing to note. I have added window.location.replace in my code because I think it suits a redirect page, but, you must know that when using window.location.replace and you get redirected, when you press the back button in your browser it will not got back to the redirect page, and it will go back to the page before it, take a look at this little demo thing.


>The process: store home => redirect page to google => google > >When at google: google => back button in browser => store home

So, if this suits your needs then everything should be fine. If you want to include the redirect page in the browser history replace this

if( url ) window.location.replace(url);


if( url ) window.location.href = url;

Solution 20 - Javascript

On your click function, just add:

window.location.href = "The URL where you want to redirect";
    window.location.href = "";

Solution 21 - Javascript

Try this:


Code snippet of example.

Solution 22 - Javascript

jQuery is not needed. You can do this:"URL","_self","","")

It is that easy!

The best way to initiate an HTTP request is with document.loacation.href.replace('URL').

Solution 23 - Javascript

Using JavaScript:

Method 1:
Method 2:

Using jQuery:

Method 1: $(location)
$(location).attr('href', '');
Method 2: Reusable Function
jQuery.fn.redirectTo = function(url){
    window.location.href = url;


Solution 24 - Javascript

First write properly. You want to navigate within an application for another link from your application for another link. Here is the code:

window.location.href = "";

And if you want to navigate pages within your application then I also have code, if you want.

Solution 25 - Javascript

You can redirect in jQuery like this:

$(location).attr('href', '');

Solution 26 - Javascript

JavaScript is very extensive. If you want to jump to another page you have three options.



As you want to move to another page, you can use any from these if this is your requirement. However all three options are limited to different situations. Chose wisely according to your requirement.

If you are interested in more knowledge about the concept, you can go through further.

window.location.href; // Returns the href (URL) of the current page
window.location.hostname; // Returns the domain name of the web host
window.location.pathname; // Returns the path and filename of the current page
window.location.protocol; // Returns the web protocol used (http: or https:)
window.location.assign; // Loads a new document
window.location.replace; // RReplace the current location with new one.

Solution 27 - Javascript

In JavaScript and jQuery we can use the following code to redirect the one page to another page:


Solution 28 - Javascript




var url='';
$(location).prop('href',url);//instead of location you can use window

Solution 29 - Javascript

ECMAScript 6 + jQuery, 85 bytes


Please don't kill me, this is a joke. It's a joke. This is a joke.

This did "provide an answer to the question", in the sense that it asked for a solution "using jQuery" which in this case entails forcing it into the equation somehow.

Ferrybig apparently needs the joke explained (still joking, I'm sure there are limited options on the review form), so without further ado:

Other answers are using jQuery's attr() on the location or window objects unnecessarily.

This answer also abuses it, but in a more ridiculous way. Instead of using it to set the location, this uses attr() to retrieve a function that sets the location.

The function is named jQueryCode even though there's nothing jQuery about it, and calling a function somethingCode is just horrible, especially when the something is not even a language.

The "85 bytes" is a reference to Code Golf. Golfing is obviously not something you should do outside of code golf, and furthermore this answer is clearly not actually golfed.

Basically, cringe.

Solution 30 - Javascript

Here is a time-delay redirection. You can set the delay time to whatever you want:

<!doctype html>
<html lang="en">

    <meta charset="UTF-8">
    <title>Your Document Title</title>
    <script type="text/javascript">
        function delayer(delay) {
            onLoad = setTimeout('window.location.href = ""', delay);

    <div>You will be redirected in 8 seconds!</div>


Solution 31 - Javascript

There are three main ways to do this,




The last one is best, for a traditional redirect, because it will not save the page you went to before being redirected in your search history. However, if you just want to open a tab with JavaScript, you can use any of the above.1

EDIT: The window prefix is optional.

Solution 32 - Javascript

I just had to update this ridiculousness with yet another newer jQuery method:

var url = '';
$(location).prop('href', url);

Solution 33 - Javascript

Write the below code after the PHP, HTML or jQuery section. If in the middle of the PHP or HTML section, then use the <script> tag.

location.href = ""

Solution 34 - Javascript

jQuery code to redirect a page or URL

> First Way

Here is the jQuery code for redirecting a page. Since, I have put this code on the $(document).ready() function, it will execute as soon as the page is loaded.

var url = "";

You can even pass a URL directly to the attr() method, instead of using a variable.

> Second Way


You can also code like this (both are same internally):


If you are curious about the difference between window.location and window.location.href, then you can see that the latter one is setting href property explicitly, while the former one does it implicitly. Since window.location returns an object, which by default sets its .href property.

> Third Way

There is another way to redirect a page using JavaScript, the replace() method of window.location object. You can pass a new URL to the replace() method, and it will simulate an HTTP redirect. By the way, remember that window.location.replace() method doesn't put the originating page in the session history, which may affect behavior of the back button. Sometime, it's what you want, so use it carefully.

// Doesn't put originating page in history

> Fourth Way

like attr() method (after jQuery 1.6 introduce)

var url = "";
$(location).prop('href', url);

Solution 35 - Javascript

In jQuery, use $(location).attr('href', url):

    var url = "";
    $(location).attr('href', url); // Using this

<script src=""></script>

In raw JavaScript, there are a number of ways to achieve that:


Here is an example of JavaScript redirecting after a certain time (3 seconds):

    setTimeout(function() {
        window.location.href = "";
    }, 3000);

Solution 36 - Javascript

In JavaScript and jQuery we use this following code to redirect the page:


But you can make a function in jQuery to redirect the page:


And call this function:


Solution 37 - Javascript

Use the jQuery function:

  redirectPost: function(location, args) {
    var form = '';
    $.each(args, function(key, value) {
      form += '<input type="hidden" name="' + key + '" value="' + value + '">';
    $('<form action="' + location + '" method="POST">' + form + '</form>').appendTo($(document.body)).submit();

In your code you use it like this:

$.redirectPost("addPhotos.php", {pimreference:  $("#pimreference").val(), tag: $("#tag").val()});

Solution 38 - Javascript

Simply in JavaScript, you can redirect to a specific page by using the following:





window.location.href = "";

Using jQuery:


Solution 39 - Javascript

You can use it like in the following code where getRequestToForwardPage is the request mapping (URL). You can also use your URL.

function savePopUp(){
        data: $("#popForm").serialize(),
        dataType: "json",
        error: (function() {
            alert("Server Error");
    success: function(map) {
        window.location = "getRequestToForwardPage";

This is for the same context of the application.

If you want to use only jquery specific code then following code may help:


Solution 40 - Javascript

<script type="text/javascript">
var url = "";

// IE8 and lower fix
if (navigator.userAgent.match(/MSIE\s(?!9.0)/))
    var referLink = document.createElement("a");
    referLink.href = url;

// All other browsers
else { window.location.replace(url); }

Solution 41 - Javascript

Using location.replace() will redirect you, but without saving the history of the previous page. This is better to use when a form is submitted.

But when you want to keep your history you have to use location.href=//path.


// Form with steps
document.getElementById('#next').onclick = function() {
   window.location.href='/step2' // Iteration of steps;

// Go to next step
document.getElementById('#back').onclick = function() {

// Finish
document.getElementById('#finish').onclick = function() {
   window.location.href = '/success';

// On success page
window.onload = function() {
    setTimeout(function() {
       window.location.replace('/home'); // I can't go back to success page by pressing the back button

Solution 42 - Javascript

You can write the Url.Action for the Button click event in the script section as follows.

function onclick() {
    location.href = '@Url.Action("Index", "Home")';

Solution 43 - Javascript

Here is the code to redirect to some other page with a timeout of 10 seconds.

    function Redirect()

    document.write("You will be redirected to a new page in 10 seconds.");
    setTimeout('Redirect()', 10000);

You can also do it like this, on click of a button using location.assign:

<input type="button" value="Load new document" onclick="newPage()">
    function newPage() {

Solution 44 - Javascript

This is very easy to implement. You can use:

window.location.href = "";

This will remember the history of the previous page. So one can go back by clicking on the browser's back button.



This method does not remember the history of the previous page. The back button becomes disabled in this case.

Solution 45 - Javascript

If you prefer to use pure JavaScript I realized that using of document.location.href = "" or window.location.href = "" causes compatibility issues in Firefox. Instead try to use:

location.href = "";

In my case has solved the problem. Good luck!

Solution 46 - Javascript

You can use:


The replace() method does not save the originating page in the session history, so the user can't go back using the back button and again get redirected. NOTE: The browser back button will be deactivated in this case.

However, if you want an effect the same as clicking on a link you should go for:

window.location.href = "";

In this case, the browser back button will be active.

Solution 47 - Javascript


function redirect(a) {
    location = a

And call it with: redirect([url]);

There's no need for the href after location, as it is implied.

Solution 48 - Javascript

<script type="text/javascript">
    if(window.location.href === "") {      

Solution 49 - Javascript

Single Page Application, within the same application route

window.location.pathname = '/stack';


location.href = "";
window.location = "";


$(location).attr('href', "");
$(window).attr('location', "");

Angular 4

import { Router } from '@angular/router';
export class NavtabComponent{
    constructor(private router: Router) {

Solution 50 - Javascript

I just add another way:

To redirect for any specific page/links of your site to another page, just add this line of code:

    if(window.location.href == 'old_url')

    // Another URL redirect
    if(window.location.href == 'old_url2')

For a real life example,

    if(window.location.href == '')

    // Another URL redirect
    if(window.location.href == '')

By using this simple code, you can redirect full site or any single page.

Solution 51 - Javascript

  1. location.assign():

    To assign a route path by passing a path into it.. Assign will give you a history even after the path was assigned.

    Usage Method: value should be passed into it.

    For example: location.assign("")

    Enter image description here

  2. location.href

    Can define give a path into it... And it will redirect into a given path once it setup, and it will keep history...

    Usage Method: value should be assign into it.

    For example: location.href = ""

  3. location.replace():

    It will help to replace a path if you don't want to keep history. It won't give you a history once you replace its path.

    Usage Method: value should be pass into it.

    For example: location.replace("")

    Enter image description here

assign() and href are similar, and both can hold history. assign will work by passing a value and href works by assigning.

You can achieve it using JavaScript itself without using jQuery by assigning,

window.location = ""
location.href = ""

You can achieve similar thing using jQuery like below. It will do exactly the same like above,

$(window).attr('location', "");
$(location).attr('href', "");

You can easily understand the difference between both...

Here is the Location object,

Location API from chrome

Solution 52 - Javascript

You can redirect the page by using the below methods:

  1. By using a meta tag in the head - <meta http-equiv="refresh" content="0;url=" />. Note that content="0;... is used for after how many seconds you need to redirect the page

  2. By using JavaScript: window.location.href = "";

  3. By using jQuery: $(location).attr('href', '');

Solution 53 - Javascript

I already use the function redirect() of JavaScript. It's working.

<script type="text/javascript">
	$(function () {
		//It's similar to HTTP redirect
		//It's similar to clicking on a link
		window.location.href = "Http://";

Solution 54 - Javascript

If you want to redirect to a route within the same app simply

window.location.pathname = '/examplepath'

would be the way to go.

Solution 55 - Javascript

All way to make a redirect from the client side:

<!DOCTYPE html>
        <title>JavaScript and jQuery example to redirect a page or URL </title>
        <div id="redirect">
            <h2>Redirecting to another page</h2>

        <script src="scripts/jquery-1.6.2.min.js"></script>
            // JavaScript code to redirect a URL
            // window.location.replace('');

            // Another way to redirect page using JavaScript

            // window.location.assign('');
            // window.location.href = '';
            // document.location.href = '/relativePath';

            //jQuery code to redirect a page or URL
                //var url = "";
                // $(window).attr('location',url)
                //$(location).prop('href', url)

Solution 56 - Javascript

Redirecting User using jQuery/JavaScript

By using the location object in jQuery or JavaScript we can redirect the user to another web page.

In jQuery

The code to redirect the user from one page to another is:

var url = '';
$(location).attr('href', url);

In JavaScript

The code to redirect the user from one page to another is:

var url = '';
window.location.href = url;


var url = '';
window.location = url;

Solution 57 - Javascript

In my work experience, JavaScript is much better to redirect.

It depends on how you want to change the location. If you want to log your website in users history, use window.location.href='ur website';. Otherwise to do it without logging in history, use window.location.replace("your website");.

Solution 58 - Javascript

This is how I use it.

   // If you're on root and redirection page is also on the root

   window.location.replace( + '/subDirectory/yourPage.aspx');

   // If you're in sub directory and redirection page is also in some other sub directory.


All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionvenkatachalamView Question on Stackoverflow
Solution 1 - JavascriptRyan McGearyView Answer on Stackoverflow
Solution 2 - JavascriptBoris GuéryView Answer on Stackoverflow
Solution 3 - JavascriptMark Pieszak - Trilon.ioView Answer on Stackoverflow
Solution 4 - JavascriptGovind SinghView Answer on Stackoverflow
Solution 5 - JavascriptFredView Answer on Stackoverflow
Solution 6 - JavascripttvanfossonView Answer on Stackoverflow
Solution 7 - JavascriptPatartics MilánView Answer on Stackoverflow
Solution 8 - JavascriptNadeem YasinView Answer on Stackoverflow
Solution 9 - JavascriptNikhil AgrawalView Answer on Stackoverflow
Solution 10 - JavascriptAlirezaView Answer on Stackoverflow
Solution 11 - JavascriptNewseView Answer on Stackoverflow
Solution 12 - JavascriptPatrick W. McMahonView Answer on Stackoverflow
Solution 13 - Javascriptuser188973View Answer on Stackoverflow
Solution 14 - JavascriptScoRpionView Answer on Stackoverflow
Solution 15 - JavascriptxloadxView Answer on Stackoverflow
Solution 16 - JavascriptSakthi KarthikView Answer on Stackoverflow
Solution 17 - JavascriptSergeDirectView Answer on Stackoverflow
Solution 18 - JavascriptAshish RatanView Answer on Stackoverflow
Solution 19 - JavascriptiConnorView Answer on Stackoverflow
Solution 20 - JavascriptSwaprksView Answer on Stackoverflow
Solution 21 - JavascripttilakView Answer on Stackoverflow
Solution 22 - JavascriptbrenView Answer on Stackoverflow
Solution 23 - JavascriptKalpesh PanchalView Answer on Stackoverflow
Solution 24 - JavascriptAnupView Answer on Stackoverflow
Solution 25 - JavascriptAzam AlviView Answer on Stackoverflow
Solution 26 - JavascriptMustkeem KView Answer on Stackoverflow
Solution 27 - Javascriptuser2496033View Answer on Stackoverflow
Solution 28 - JavascriptlalithkumarView Answer on Stackoverflow
Solution 29 - Javascript1j01View Answer on Stackoverflow
Solution 30 - JavascriptStefan GruenwaldView Answer on Stackoverflow
Solution 31 - JavascriptBenView Answer on Stackoverflow
Solution 32 - JavascriptEpiphanyView Answer on Stackoverflow
Solution 33 - JavascriptBidyutView Answer on Stackoverflow
Solution 34 - JavascriptDivyesh KanzariyaView Answer on Stackoverflow
Solution 35 - JavascriptTaufiq RahmanView Answer on Stackoverflow
Solution 36 - JavascriptMuhammad WaqasView Answer on Stackoverflow
Solution 37 - JavascriptstratumView Answer on Stackoverflow
Solution 38 - Javascriptvipul sorathiyaView Answer on Stackoverflow
Solution 39 - JavascriptVinay SharmaView Answer on Stackoverflow
Solution 40 - JavascriptJaydeep JadavView Answer on Stackoverflow
Solution 41 - JavascriptAndrei TodorutView Answer on Stackoverflow
Solution 42 - Javascriptwild coderView Answer on Stackoverflow
Solution 43 - JavascriptAdarsh Gowda K RView Answer on Stackoverflow
Solution 44 - JavascriptAbhishek K. UpadhyayView Answer on Stackoverflow
Solution 45 - JavascriptAlessandro Foolish Ciak DAntonView Answer on Stackoverflow
Solution 46 - JavascriptmadhurView Answer on Stackoverflow
Solution 47 - Javascriptcascading-styleView Answer on Stackoverflow
Solution 48 - JavascriptsnehaView Answer on Stackoverflow
Solution 49 - JavascriptHD..View Answer on Stackoverflow
Solution 50 - JavascriptManiruzzaman AkashView Answer on Stackoverflow
Solution 51 - JavascriptMohideen bin MohammedView Answer on Stackoverflow
Solution 52 - JavascriptSantoshKView Answer on Stackoverflow
Solution 53 - Javascriptuser1012506View Answer on Stackoverflow
Solution 54 - JavascriptRuNpiXelruNView Answer on Stackoverflow
Solution 55 - JavascriptZigri2612View Answer on Stackoverflow
Solution 56 - Javascriptdevst3rView Answer on Stackoverflow
Solution 57 - JavascriptomkaartgView Answer on Stackoverflow
Solution 58 - JavascriptdnxitView Answer on Stackoverflow