js页面跳转常用的几种方式

js页面跳转常用的几种方式

第一种:

复制代码 代码如下:


<script language="javascript" type="text/javascript">
window.location.href="jb51.jsp?backurl="+window.location.href;
</script>


第二种:

复制代码 代码如下:


<script language="javascript">
alert("返回");
window.history.back(-1);
</script>


第三种:

复制代码 代码如下:


<script language="javascript">
window.navigate("jb51.jsp");
</script>


第四种:

复制代码 代码如下:


<script language="JavaScript">
self.location='jb51.htm';
</script>


第五种:

复制代码 代码如下:


<script language="javascript">
alert("非法访问!");
top.location='jb51.jsp';
</script>


第六种:网址从传参获得并转向

复制代码 代码如下:


<script language="javascript" type="text/javascript">
function request(paras){
var url = location.href;
var paraString = url.substring(url.indexOf("?")+1,url.length).split("&");
var paraObj = {}
for (i=0; j=paraString[i]; i++){
paraObj[j.substring(0,j.indexOf(“=”)).toLowerCase()] = j.substring(j.indexOf("=")+1,j.length);
}
var returnValue = paraObj[paras.toLowerCase()];
if(typeof(returnValue)=="undefined"){
return "";
}else{
return returnValue;
}
}
var theurl
theurl=request("url");
if (theurl!=''){
location=theurl
}
</script>

修改时间

2017/11/18 09:49

Team Members:
friend

Comments (258)

Generic placeholder image
Jeremy Tomlinson
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
Generic placeholder image
Kathleen Thomas
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
Progress
Settings

Basic Settings


Recent Activity

You sold an item Paul Burgess just purchased “Hyper - Admin Dashboard”!

5 minutes ago

Product on the Bootstrap Market Dave Gamache added Admin Dashboard

30 minutes ago

Robert Delaney Send you message "Are you there?"

2 hours ago

Audrey Tobey Uploaded a photo "Error.jpg"

14 hours ago

You sold an item Paul Burgess just purchased “Hyper - Admin Dashboard”!

1 day ago