window.location.href和window.location.replace的区别
有3个html页面(.html, .html, .html)。 进系统默认的是1.html ,当我进入2.html的时候,
.html里面用window.location.replace("3.html");与用window.location.href("3.html");
从用户界面来看是没有什么区别的,
但是当3.html页面有一个“返回”按钮,调用window.history.go(-);wondow.history.back();
方法的时候,一点这个返回按钮就要返回2.html页面的话,区别就出来了,
当用window.location.replace("3.html");连到3.html页面的话,
.html页面中的调用window.history.go(-);wondow.history.back();方法是不好用的,会返回到1.html
。
当用window.location.href("3.html");连到3.html页面的话,
.html页面中的调用window.history.go(-);wondow.history.back();方法是好用的,会返回2.html。
因为window.location.replace("3.html");是不向服务器发送请求的跳转,
而window.history.go(-);wondow.history.back();方法是根据服务器记录的请求决定该跳到哪个页面的,
所以会跳到系统默认页面1.html 。window.location.href("3.html");是向服务器发送请求的跳转,window.history.go(-);wondow.history.back();方法是根据服务器记录的请求决定该跳到哪个页面的,
所以就可以返回到2.html。
window.location.href和window.location.replace的区别的更多相关文章
- window.location.href 和 window.location.replace 的区别
window.location.href 和 window.location.replace 的区别 1.window.location.href=“url”:改变url地址: 2.window. ...
- window.location.href 与 window.loaction.replace区别
window.location.href和window.location.replace的区别 1.window.location.href=“url”:改变url地址: 2.window.locat ...
- 关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法
location.href 和 window.location.href 区别: 1.location.href 可以直接跳转其他地址(不属于本项目) 也可以跳转本项目中的 2.window.loca ...
- window.location.href和window.open的几种用法和区别
使用js的同学一定知道js的location.href的作用是什么,但是在js中关于location.href的用法究竟有哪几种,究竟有哪些区别,估计很多人都不知道了. 一.location.href ...
- window.location.href和document.location.href、document.URL的区别
1.document表示的是一个文档对象,window表示的是一个窗口对象,一个窗口下可以有多个文档对象. 所以一个窗口下只有一个window.location.href,但是可能有多个documen ...
- window.location.href.substr(window.location.href.length - 6)
if (window.location.href.substr(window.location.href.length - 6) == "flag=1") { var tOptio ...
- window.location和window.location.href和document.location的关系
1,首先来区分window.location和window.location.href. window.location.href是一个字符串. 而window.location是一个对象,包含属性有 ...
- window.top.location.href 和 window.location.href 的区别
"window.location.href"."location.href"是本页面跳转. "parent.location.href" 是 ...
- window.location.href 和 document.location.href
document表示的是一个文档对象,window表示的是一个窗口对象,一个窗口下可以有多个文档对象. 所以一个窗口下只有一个window.location.href,但是可能有多个document. ...
随机推荐
- DOM高级
表格应用 获取 tBodies, tHead, tFoot, rows, cells 隔行变色 鼠标移入高亮, 添加,删除一行 DOM的方法使用 <!DOCTYPE html PUBLIC &q ...
- phpcms评论的url替换问题
在整个项目改ip之前,评论里的url是127.0.1.113 改成localhost之后,更新了所有的url和缓存,但是v9_comment表中的url字段没有更新. 想一下后台只有一个地方是替换数据 ...
- XAMPP端口占用启动不了
skype默认会占用80和443端口 如果在apache之前启动skype,apache就会启动不了了!! 解决办法很简单: 1. 先启动apache再启动skype,这样skype就会换其他的端口监 ...
- PHPCMS V9教程之快速入门
这篇文章要为大家来介绍PHPCMS V9这个系统的一些基本知识,PHPCMS是基于面向对象的,严格的安装MVC开发模式开发的CMS系统,同时他还是一个非 常不错的PHP框架.下面我们一起看一下PHPC ...
- JAVA调用动态链接库DLL之JNative学习
package com.ehfscliax; import java.io.UnsupportedEncodingException;import java.net.URLEncoder;import ...
- C++ 代码头注释模板
/********************************************************************************* *Copyright(C),You ...
- POJ 1088
http://poj.org/problem?id=1088 一道中文题,这道题如果不限时的话,是个简单的搜索,但限时的话,就要用记忆化搜索 所谓记忆化搜索就是对每一次搜索的结果进行记录,然后之后的如 ...
- Appium+Robotframework实现Android应用的自动化测试-1:Appium在Windows中的安装
让我们开始在Windows中开始安装Appium吧,Appium在OS X中的具体安装后面的文章会介绍. 另外,官网上说先要装Node.js,还要装Apache Ant和Apache Maven,Gi ...
- ios UITextView 计算文字内容大小
先设置好 textView的内容文字,再调用以下代码,就能够得到文字内容的size,其中参数表示最大的size的尺寸,通常,高度应该不限制,宽度是控件的宽度. let newSize = statem ...
- nyoj_148_fibonacci数列(二)_矩阵快速幂
fibonacci数列(二) 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 In the Fibonacci integer sequence, F0 = 0, F ...