您的位置:首页 > Web前端 > JavaScript

How to redirect page in JavaScript

2013-06-05 17:15 316 查看
window.location
= “xxx.html”;
 (or
window.location.href

= "xxx.html";)

window.location.replace("xxx.html")


NOTE: The second one is better than
the first one
, because
replace()
does not put 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
.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: