JavaScript 页面跳转的几种方式 转
第一种:
<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>
window.location="";和 location.replace("");有什么区别?
这两个都能让网页导向令一个网址,那么有什么区别呢?比如能带参数,不能带参数之类的.
Replace?还是Reload()?
好像没什么区别吧?没试过
replace(),reload()是重新加载本页,而replace()可以导向另外一个URL
给你举个例子:
我们现在有3个页面(a.html, b.html, c.html).
默认打开a.html页面,然后在a.html页面中通过一个链接转向a.html页面。
现在,我在b.html页面中用window.location.replace("c.html");与用window.location.href("c.html");分别进入c.html页面.
从用户界面来看是没有什么区别的,但是现在c.html页面有一个“返回”按钮,
用window.location.href("c.html");进入c.html页面时,
c.html页面中的调用window.history.Go(-1);wondow.history.back();进入c.html页面时,一点这个"返回"按钮就要返回b.html页面的话,
而如果用window.location.replace("c.html");进入c.html页面的话,
c.html页面中的调用window.history.go(-1);wondow.history.back();方法是不好用的,会返回到a.html.
因为window.location.replace("c.html");是不会向服务器发送请求而进行跳转,而window.history.go(-1);wondow.history.back();方法是根据服务器记录的请求决定该跳到哪个页面的,所以会跳到系统默认页面a.html 。
window.location.href("c.html");是向服务器发送请求的跳转,window.history.go(-1);wondow.history.back();方法是根据服务器记录的请求决定该跳到哪个页面的,所以就可以返回到b.html。
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 ...
随机推荐
- Shopping(hdu 3768)
题意:给你一个无向图,求从0号点开始遍历所有的指定点再回到0号点的最短路径 #include<cstdio> #include<iostream> #include<qu ...
- 6.原型模式(Prototype Pattern)
using System; namespace ConsoleApplication5 { class Program { static void Main(string[] args) { // 孙 ...
- IIS-如果外网访问不到 域名
如果访问不到 域名 , 可以 给域名的目录 增加“IIS_IUSERS”权限.
- 【vijos1066】弱弱的战壕 线段树
描述 永恒和mx正在玩一个即时战略游戏,名字嘛~~~~~~恕本人记性不好,忘了-_-b. mx在他的基地附近建立了n个战壕,每个战壕都是一个独立的作战单位,射程可以达到无限(“mx不赢定了?!?”永恒 ...
- 电赛总结(四)——波形发生芯片总结之AD9834
一.特性参数 1.2.3V~5.5V供电 2.输出频率高达37.5MHz 3.正弦波.三角波输出 4.提供相位调制和频率调制功能 5.除非另有说明,VDD = 2.3 V至5.5 V,AGND = D ...
- C#学习笔记(六)——面向对象编程简介
一.面向对象编程的含义 * 是一种模块化编程方法,使代码的重用性大大的增加. * oop技术使得项目的设计阶段需要的精力大大的增加,但是一旦对某种类型的数据表达方式达成一致,这种表达方式就可以 ...
- CRC-16/XMODE X16+X12+X5+1 C#、C和java环境下实现
private byte[] CRC(byte[] x, int len) //CRC校验函数 { ]; UInt16 crc = ; byte da; ; UInt16[] yu = { 0x000 ...
- http://www.open-open.com/lib/view/open1397274257325.html
http://www.open-open.com/lib/view/open1397274257325.html
- 算法教程(1)zz
Introduction Many TopCoders seem to be mortally afraid of geometry problems. I think it's safe to sa ...
- 获取当前的时间,转化为char[]格式unix时间戳
/* 在这个程序当中实现获取当前的unix时间戳 转化为char[] */ #include<stdio.h> #include<stdlib.h> #include<t ...