首页 > 编程语言 > 详细

[Javascript] Redirect the browser using JavaScript

时间:2016-01-31 21:18:24      阅读:179      评论:0      收藏:0      [点我收藏+]

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

原文:http://www.cnblogs.com/Answer1215/p/5173626.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!