js页面跳转
2016-07-20 13:05
489 查看
js方式的页面跳转
1.window.location.href方式
<script language="javascript" type="text/javascript">
window.location.href="next.php";
</script>
2.window.navigate方式跳转
<script language="javascript">
window.navigate("next.php");
</script>
3.window.loction.replace方式实现页面跳转,注意跟第一种方式的区别
<script language="javascript">
window.location.replace("next.php");
</script>
有3个php页面(1.php, 2.php, 3.php),进系统默认的是1.php,当我进入2.php的时候, 2.php里面用window.location.replace("3.php");
与用window.location.href ("3.php");
从用户界面来看是没有什么区别的,但是当3.php页面有一个"返回"按钮,调用window.history.go(-1); wondow.history.back();方法的时候,一点这个返回按钮就要返回2.php页面的话,区别就出来了,当用
window.location.replace("3.php");连到3.php页面的话,3.php页面中的调用 window.history.go(-1);wondow.history.back();方法是不好用的,会返回到1.php。
4.self.location方式实现页面跳转,和下面的top.location有小小区别
<script language="JavaScript">
self.location='next.php';
</script>
5.top.location
<script language="javascript">
top.location='next.php';
</script>
6.不推荐这种方式跳转
<script language="javascript">
alert("返回");
window.history.back(-1);
</script>
7.在新窗口打开页面
<script language="javascript">
window.open("http://www.jb51.net");
</script>
meta方式实现跳转(content = 3 单位是秒)
<meta http-equiv=refresh content=3;URL="http://www.dayanmei.com">
总结二:
1. Javascript 返回上一页 history.go(-1), 返回两个页面: history.go(-2);
2. history.back().
3. window.history.forward()返回下一页
4. window.history.go(返回第几页,也可以使用访问过的URL)
例:
<a href="javascript:history.go(-1);">向上一页</a>
response.Write("<script language=javascript>")
response.Write("if(!confirm('完成任务?')){history.back();}")
response.Write("</script>")
response.Write("<script language=javascript>history.go(-1);</script>")
<a href="javascript:history.go(-1);">向上一页</a>
页面跳转:onclick="window.location.href='list.next.php'"
1.window.location.href方式
<script language="javascript" type="text/javascript">
window.location.href="next.php";
</script>
2.window.navigate方式跳转
<script language="javascript">
window.navigate("next.php");
</script>
3.window.loction.replace方式实现页面跳转,注意跟第一种方式的区别
<script language="javascript">
window.location.replace("next.php");
</script>
有3个php页面(1.php, 2.php, 3.php),进系统默认的是1.php,当我进入2.php的时候, 2.php里面用window.location.replace("3.php");
与用window.location.href ("3.php");
从用户界面来看是没有什么区别的,但是当3.php页面有一个"返回"按钮,调用window.history.go(-1); wondow.history.back();方法的时候,一点这个返回按钮就要返回2.php页面的话,区别就出来了,当用
window.location.replace("3.php");连到3.php页面的话,3.php页面中的调用 window.history.go(-1);wondow.history.back();方法是不好用的,会返回到1.php。
4.self.location方式实现页面跳转,和下面的top.location有小小区别
<script language="JavaScript">
self.location='next.php';
</script>
5.top.location
<script language="javascript">
top.location='next.php';
</script>
6.不推荐这种方式跳转
<script language="javascript">
alert("返回");
window.history.back(-1);
</script>
7.在新窗口打开页面
<script language="javascript">
window.open("http://www.jb51.net");
</script>
meta方式实现跳转(content = 3 单位是秒)
<meta http-equiv=refresh content=3;URL="http://www.dayanmei.com">
总结二:
1. Javascript 返回上一页 history.go(-1), 返回两个页面: history.go(-2);
2. history.back().
3. window.history.forward()返回下一页
4. window.history.go(返回第几页,也可以使用访问过的URL)
例:
<a href="javascript:history.go(-1);">向上一页</a>
response.Write("<script language=javascript>")
response.Write("if(!confirm('完成任务?')){history.back();}")
response.Write("</script>")
response.Write("<script language=javascript>history.go(-1);</script>")
<a href="javascript:history.go(-1);">向上一页</a>
页面跳转:onclick="window.location.href='list.next.php'"
相关文章推荐
- JQuery1——基础($对象,选择器,对象转换)
- Android学习笔记(二九):嵌入浏览器
- Android java 与 javascript互访(相互调用)的方法例子
- Extjs4.0 最新最全视频教程
- Javascript中toFixed方法的改进
- JavaScript演示排序算法
- javascript实现10进制转为N进制数
- 5个常见可用性错误和解决方案
- 最后一次说说闭包
- Ajax
- js数组实现图片轮播
- 2019年开发人员应该学习的8个JavaScript框架
- HTML中的script标签研究
- 对一个分号引发的错误研究
- 异步流程控制:7 行代码学会 co 模块
- ES6 走马观花(ECMAScript2015 新特性)
- JavaScript拆分字符串时产生空字符的原因
- Canvas 在高清屏下绘制图片变模糊的解决方法