第一种:直接跳转加参数
<script language="javascript" type="text/javascript">window.location.href="login.jsp?backurl="+window.location.href; </script>
直接跳转无参数:
<script>window.location.href='http://www.baidu.com';</script>
第二种:返回上一次预览界面
<script language="javascript">alert("返回");window.history.back(-1);</script>
标签嵌套:
<a href="javascript:history.go(-1)">返回上一步</a><a href="<%=request.servervariables("http_referer")%>">返回上一步</a>
第三种:指定跳转页面 对框架无效
<script language="javascript"> window.navigate("top.jsp"); </script>
第四种:指定自身跳转页面 对框架无效
<script language="javascript"> self.location='top.htm'; </script>
第五种:指定自身跳转页面 对框架有效
<script language="javascript"> alert("非法访问!"); top.location='xx.aspx'; </script>
第六种:按钮式 在button按钮添加事件跳转
<input name="pclog" type="button" value="go" onclick="location.href='login.aspx'">
第七种:在新窗口打开
<a href="javascript:" onclick="window.open('login.aspx','','height=500,width=611,scrollbars=yes,status=yes')">开新窗口</a>
示例:
<head> <script language="javascript">function old_page() { window.location = "login.aspx" } function replace() { window.location.replace("login.aspx") } function new_page() { window.open("login.aspx") } </script> </head> <body> <input type="button" onclick="new_page()" value="在新窗口打开s"/> <input type="button" onclick="old_page()" value="跳转后有后退功能"/> <input type="button" onclick="replace()" value="跳转后没有后退功能"/> </body>
更多编程相关知识,请访问:编程教学!!
以上就是7种利用js实现页面跳转的方法(分享)的详细内容。