使用 JS 实现页面跳转的几种方式总结,小菜一碟!

对于大多数前端开发人员,经常用到的就是页面跳转功能吧,下面简单总结了几种页面跳转功能的实现,供大家参考使用。

第一种:使用JS跳转页面

1)跳转带参

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

2)跳转无参

<script>window.location.href='http://blog.yoodb.com';</script>

第二种:返回上一次预览界面

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

HTML页面嵌套

<a href="javascript:history.go(-1)">返回上一步</a>
<a href="<%=Request.ServerVariables("HTTP_REFERER")%>">返回上一步</a>

第三种:button按钮添加事件跳转

<input name="前端知音" type="button" value="前端知音" onClick="location.href='login.do'">

第四种:在新窗口打开

 <a href="javascript:" onClick="window.open('login.do','','height=500,width=611,scrollbars=yes,status=yes')">新窗口</a>

第五种:通过meta设置跳转页面

<head>
    <!--只刷新不跳转 -->
    <meta http-equiv="refresh" content="5">
    <!--定时跳转 -->
    <meta http-equiv="refresh" content="5;url=index.html"> 
</head>

版权声明:本文为afreon原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。