Javascript实现页面跳转的几种方式
概述
相信很多Web开发者都知道,在开发Web程序的时候,对于页面之间的跳转,有很多种,但是有效的跳转则事半功倍,下面就是我在平时的开发过程中所用到的一些JavaScript跳转方式,拿出和大家共享一下。
第一种:直接跳转加参数
<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>

Javascript实现页面跳转的几种方式的更多相关文章
- js实现页面跳转的两种方式
CreateTime--2017年8月24日08:13:52Author:Marydon js实现页面跳转的两种方式 方式一: window.location.href = url 说明:我们常用 ...
- web页面跳转的几种方式
可用客户端触发或服务端触发的方式来实现页面跳转. 客户端触发 方式一:使用Javascript 利用window.location对象的href属性.assign()方法或replace()方法来实现 ...
- php实现页面跳转的几种方式
PHP中实现页面跳转有一下几种方式,看了几个人写的不是很条理,自己整理一下 在PHP脚本代码中实现 <?php header("location:url地址") ?> ...
- PHP 页面跳转的三种方式
第一种方式:header() header()函数的主要功能是将HTTP协议标头(header)输出到浏览器. 语法: void header ( string $string [, bool $re ...
- web项目中实现页面跳转的两种方式
<a href="javascript:"></a>跳转在网页本身,URL不改变 <a href="#"></a> ...
- 微信小程序页面跳转 的几种方式
最近在做微信小程序,碰到页面跳转的问题,总结一下页面之间跳转的方式 一.wx.navigateTo(OBJECT) 这是最普遍的一种跳转方式,其官方解释为:“保留当前页面,跳转到应用内的某个页面” 类 ...
- 微信小程序页面跳转的三种方式总结
原文链接 https://blog.csdn.net/zgmu/article/details/72123329 首先我们了解到,小程序规定页面路径只能有五层,所以我们尽量避免多层级的页面跳转 页面跳 ...
- Vue路由实现页面跳转的两种方式(router-link和JS)
Vue.js 路由可以通过不同的 URL 访问不同的内容,实现多视图的单页 Web 应用 1.通过 <router-link> 实现 <router-link> 组件用于设置一 ...
- Servlet页面跳转的两种方式
一.页面跳转 1. 请求转发: (1) 使用requestDispatcher对象: 转发格式:request.getRequestDispatcher("path").forwa ...
随机推荐
- Unity3D LuaComponent(基于ulua)
LuaComponent可以支持配一个需要执行在这个gameObject上的lua脚本,并且每个gameObject上的lua都是一个实例 using UnityEngine; using LuaIn ...
- oracle导入导出数据
导入数据,cmd imp 导出数据,cmd exp
- 移动端web开发技巧
META相关 1. 添加到主屏后的标题(IOS)
- MAC 远程桌面链接 证书或链接无效
RDC --> 首选项 --> 安全性 --> 勾选即使验证失败也要链接. 问题解决.
- python--基础学习(五)参数位置传递、关键字传递、包裹传递及解包裹
python系列均基于python3.4环境 1.位置传递和关键字传递 代码示例 #位置传递 def fun(a,b,c): print("a: {0}, b: {1}, c: {2}&qu ...
- tp框架之数据添加
1.数组添加 //$attr = array("Code"=>"n088","Name"=>"哈萨克族"); ...
- jquery跳出each循环
答案是使用 return false; 切记哦,不是使用break;也不是直接使用return; jQuery中each类似于javascript的for循环 但不同于for循环的是在each里面不 ...
- linux安装open block chain
Compile the source code Step 1. 安装git sudo apt-get install git Step 2. 安装vagrant(ubuntu系统) 下载地址https ...
- notepad++ 中配置 python一键运行
cmd /k python "$(FULL_CURRENT_PATH)"& PAUSE & EXIT cmd /k python 表示打开Command Promp ...
- Intel VT入门
前言 传说中的VT貌似很神秘的样子,关于VT入门的资料又很少,于是研究了一番 由于资源有限,自身水平亦有限,并且是闭门造车之作,如有错误的地方请指正,不胜感激! 关于VT可以先参考海风月影写的 ...