[Javascript] Redirect the browser using JavaScript

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Javascript] Redirect the browser using JavaScript相关的知识,希望对你有一定的参考价值。

Three methods to preform redirection in browser:

  1. widnow.location.href
  2. window.location.assign
  3. window.location.replace

1 & 2, they are pretty much the same, just 1 is the property and 2 is the function, some people say use property is a little bit faster than calling a function. So they prefer using 1th.

http://stackoverflow.com/questions/10302905/location-href-property-vs-location-assign-method

1: window.location.href="http://www.egghead.io";
2: window.location.assign("http://www.egghead.io");

 

The differeces between 1 & 2 with 3 is:

 replace(), is that replace() removes the URL of the current document from the document history, meaning that it is not possible to use the "back" button to navigate back to the original document.

以上是关于[Javascript] Redirect the browser using JavaScript的主要内容,如果未能解决你的问题,请参考以下文章

Redirect the Output of systemd Service to a File

[AngularJS] Store the entry url and redirect to entry url after Logged in

Openidc with Keycloak error uthenticate(): request to the redirect_uri_path 但没有找到会话状态,客户端

我在django-allauth和github上遇到了redirect_uri_mismatch错误

javascript FV :: redirect点击领导者图片

Redirect