1.刷新当前页面:(通过给location.href赋值的方式)

window.location.href=""

eg:window.location.href="http://www.baidu.com"

2.重新加载文档:(location.reload()方法)

1)window.location.reload()window.location.reload(false)

浏览器会先判断服务器端的文件是否发生改变。

若改变:就会从服务器端响应数据给客户端来重新加载;

若未改变:就会直接从客户端的缓存中加载文档。

2)window.location.reload(true)

会直接从服务器端响应数据给客户端

3.使用新文档替换旧文档

window.location.replace()

eg:window.location.replace("http://www.baidu.com")

该方法的替换是:指定URL替换当前缓存在历史记录中(客户端)的项目。所以,在使用该方法后,不能通过点击“前进”“后退”按钮来访问已经被替换的URL。

在实际应用中,在刷新页面的时候,我们通常使用location.reload()或者history.go(0)方法来实现。

4.加载新文档(location.assign()方法通过加载URL指定新的文档来实现页面跳转)

window.location.assign()

eg:window.location.assign("http://www.baidu.com")

assign()与replace()方法的区别:assign():可以点击“后退”按钮返回上一个页面

assign()与href属性的区别:href是通过控制属性来实现页面跳转的

备注:window.history.back(0):可以实现当前页面的刷新功能

DOM-window下的常用子对象-location-刷新页面的更多相关文章

  1. window.history.go(-1)返回且刷新页面

    windows窗口对象(历史)history.go(),history.back(),history.forward(). 因为windows对象引用不是必须的.所以windows.history.g ...

  2. window.history.go(-1)返回且刷新页面 点击返回上一层

    windows窗口对象(历史)history.go(),history.back(),history.forward(). 因为windows对象引用不是必须的.所以windows.history.g ...

  3. text输入框中按下enter键时阻止刷新页面

    1.在js中加入一个方法: function judge_enter(){ if(window.event.keyCode==13){ return false;//阻止页面刷新的作用 } } 2.然 ...

  4. vue部署到nginx服务下,非根目录,刷新页面404怎么解决?

    nginx配置 location / { proxy_pass http://xxxx; } location /category { root /home/tv; index index.html; ...

  5. 关于vue部署到nginx服务下,非根目录,刷新页面404的问题

    如果在根目录则添加 try_files $uri $uri/ /index.html; 如果不在根目录则添加,格式如下 location  /xxxx  { try_files $uri $uri/ ...

  6. JS刷新页面总和!多种JS刷新页面代码!

    1)<meta http-equiv="refresh"content="10;url=跳转的页面">10表示间隔10秒刷新一次2)<scri ...

  7. js 刷新页面window.location.reload();

    Javascript刷新页面的几种方法:1    history.go(0)2    window.location.reload() window.location.reload(true) 3   ...

  8. window下nginx的常用命令

    window nginx 启动 常用命令 2016-05-04 11:11 214人阅读 评论(0) 收藏 举报 分类: nginx(5) 版权声明:本文为博主原创文章,未经博主允许不得转载. 启动 ...

  9. javascript:window.location.replace 与 window.location.reload() 刷新页面的不同效果

    今天早上我发现一个问题,当一个网页的地址最后面是一个#时(比如:http://www.baidu.com/go.asp#), 执行:window.location.replace(window.loc ...

随机推荐

  1. 大数模板Java

    import java.util.*; import java.math.BigInteger; public class Main{ public static void main(String a ...

  2. 自定义 popWindow弹框 工具包

    前言:因为Android 没有像IOS一样的ActionSheet,虽然在github上看到有一些类似ActionSheet的库,总觉得不好用,不如自己写一个弹框通用类,样式全部自已来多好. Step ...

  3. COGS:313. [POI2001] 和平委员会

    313. [POI2001] 和平委员会 ★★☆   输入文件:spo.in   输出文件:spo.out   评测插件时间限制:1 s   内存限制:128 MB 题目描述 根据宪法,Bytelan ...

  4. JVM内存管理:深入Java内存区域与OOM

    Java与C++之间有一堵由内存动态分配和垃圾收集技术所围成的高墙,墙外面的人想进去,墙里面的人却想出来. 概述: 对于从事C.C++程序开发的开发人员来说,在内存管理领域,他们即是拥有最高权力的皇帝 ...

  5. C#入门篇6-4:字符串操作 string分割字符串效率比较

    //分割字符串效率比较 public static void Fund() { //1.用string.Split方法 //a.字节数组: //625毫秒/百万次 string str1 = &quo ...

  6. leetcode 【 Find Minimum in Rotated Sorted Array 】python 实现

    题目: Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7  ...

  7. Bug的类型

    美国计算机科学家.图灵奖获得者詹姆斯·尼古拉·格雷(Jim Gray),在他的著名的论文“Why do computers stop and what can be done about it?”中首 ...

  8. Leetcode 650.只有两个键的键盘

    只有两个键的键盘 最初在一个记事本上只有一个字符 'A'.你每次可以对这个记事本进行两种操作: Copy All (复制全部) : 你可以复制这个记事本中的所有字符(部分的复制是不允许的). Past ...

  9. HTML5 新增绘图功能

    <!DOCTYPE html> <html> <head lang="en"> <title></title> < ...

  10. 重做LVM文件系统之减小PV

    命令 缩小PV空间到120G,即PV上的vg00已将缩小到120G pvresize --setphysicalvolumesize 120g /dev/sda2 背景 机器上有一块900G本地的本地 ...