js跳转页面方法实现汇总
js跳转页面方法实现汇总
一、总结
1、主要是用windows对象的location属性来进行跳转
window.location.href
2、如果是a标签就直接href属性,不是a标签就onclick
二、具体方法
js跳转方法很多
1 <span id="tiao">3</span><a href="javascript:countDown"></a>布丁足迹;秒后自动跳转……<meta http-equiv=refresh content=3;url='/search/billsearch.jsp'</ul> 2 <!--脚本开始--> 3 <script language="javascript" type=""> 4 function countDown(secs){ 5 tiao.innerText=secs; 6 if(--secs>0) 7 setTimeout("countDown("+secs+")",1000); 8 } 9 countDown(3); 10 </script> 11 <!--脚本结束--> 12 13 按钮式: 14 15 <INPUT name="pclog" type="button" value="GO" onClick="location.href='http://www.ddhbb.com/'"> 16 17 链接式: 18 19 <a href="javascript:history.go(-1)">返回上一步</a> 20 <a href="<%=Request.ServerVariables("HTTP_REFERER")%>">返回上一步</a> 21 22 直接跳转式: 23 24 <script>window.location.href='http://www.ddhbb.com';</script> 25 26 开新窗口: 27 28 <a href="javascript:" onClick="window.open('http://www.ddhbb.com/blog/guestbook.asp','','height=500,width=611,scrollbars=yes,status=yes')">布丁足迹</a>
JS跳转页面参考代码
第一种:
<script language="javascript" type="text/javascript">
window.location.href="login.jsp?backurl="+window.location.href;
</script>
第二种:
<script language="javascript">
alert("返回");
window.history.back(-1);
</script>
第三种:
<script language="javascript">
window.navigate("top.jsp");
</script>
第四种:
<script language="JavaScript">
self.location='top.htm';
</script>
第五种:
<script language="javascript">
alert("非法访问!");
top.location='xx.jsp';
</script>
=====javascript中弹出选择框跳转到其他页面=====
<script language="javascript">
<!--
function logout()...{
if (confirm("你确定要注销身份吗?是-选择确定,否-选择取消"))...{
window.location.href="logout.asp?act=logout"
}
}
-->
</script>
=====javascript中弹出提示框跳转到其他页面=====
<script language="javascript">
<!--
function logout()...{
alert("你确定要注销身份吗?");
window.location.href="logout.asp?act=logout"
}
-->
</script>
[/code]