首先介绍两个方法的语法:

reload 方法,该方法强迫浏览器刷新当前页面。
语法:location.reload([bForceGet])参数: bForceGet, 可选参数, 默认为 false,从客户端缓存里取当前页。 true, 则以GET 方式,从服务端取最新的页面, 相当于客户端点击 F5("刷新")

replace 方法,该方法通过指定URL替换当前缓存在历史里(客户端)的项目,因此当使用replace方法之后,你不能通过“前进”和“后退”来访问已经被替换的URL
语法:location.replace(URL) 参数: URL

在实际应用的时候,重新刷新页面的时候,我们通常使用: location.reload() 或者是 history.go(0) 来做。因为这种做法就像是客户端点F5刷新页面,所以页面的method="post"的时候,会出现“网页过期”的提示。那是因为Session的安全保护机制。可以想到: 当调用 location.reload() 方法的时候, aspx页面此时在服务端内存里已经存在, 因此必定是 IsPostback 的。如果有这种应用: 我们需要重新加载该页面,也就是说我们期望页面能够在服务端重新被创建, 我们期望是 Not IsPostback 的。这里,location.replace() 就可以完成此任务。被replace的页面每次都在服务端重新生成。你可以这么写: location.replace(location.href)

=======================================================
<a οnclick="javascript:window.location.href=window.location.href;">

<a οnclick="javascript:window.location.reload();">

测试效果一样。表单没有提交。

<input type="submit" οnclick="javascript:window.location.reload();" value="单击" id="btnVCode" />
<input type="submit" οnclick="javascript:window.location.href=window.location.href;" value="单击" id="btnVCode" />

都提交数据

window.location.Reload()应该是刷新.(如果有数据提交的话,会提示是否提交的(是和否选项))
window.location.href=window.location.href; 是定向url提交数据

最好不要用location.reload(),而用location=location比较好,还有在模式窗口(showModalDialog和showModelessDialog)前者不能用。

reload参数有true和false,比较有意思?

避免重复提交:

protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            string nr = ((DataRowView)e.Item.DataItem).Row["GZZDS"].ToString();
            string id = ((DataRowView)e.Item.DataItem).Row["RZID"].ToString();
            string rid = ((DataRowView)e.Item.DataItem).Row["RWXH"].ToString();
            string link = "";

if (nr == "")
            {
                link = "<a href='#' οnclick=\"selectGuide2('BookDoc.aspx?type=2&Id=" + id + "&rid=" + rid + "&Rnd='+Math.random());location=location;\">选择指导书</a>";
            }
            else
            {
                string t = (ViewState["State"].ToString() == "Query" || ((DataRowView)e.Item.DataItem).Row["GZZT"].ToString() == "工作结束") ? "false" : "true";
                string path=((DataRowView)e.Item.DataItem).Row["GZZDSPath"].ToString();

link = "<a href='#' οnclick=\"EditWord('" + path + "'," + t + ")\">" + nr + "</a>";
            }

((Literal)e.Item.FindControl("Literal1")).Text = link;
        }
    }

window.location.Reload()和window.location.href  window.location.Reload()应该是刷新.(如果有数据提交的话,会提示是否提交的(是和否选项))
window.location.href=window.location.href;
是定向url提交数据

是大的区别还是是否提交数据了

function refresh()
{
//刷新页面函数
//window.focus();刷新窗口
//document.execCommand("Refresh");刷新窗口
//self.location.reload();刷新当前窗口
parent.location.reload();刷新父窗口
//aaa.location.reload();弹出窗口刷新父窗口
}   
使用window.location.replace() or window.location.href(), 来重新加载此页面不出现提示框

window.location.Reload()和window.location.href 区别相关推荐

  1. window.location.reload(false);window.location.reload(true);history.Go(0)区别

    在日常工作中常用的页面刷新方式的区别:  1 window.location.reload(false);  先说说window.location.reload(false);当我们window.lo ...

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

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

  3. window.opener.location.reload() and href()的区别

    window.opener.location.reload() and href()的区别 Posted on 2010-05-03 18:00 大椰网吧 阅读(3652) 评论(0) 编辑 收藏 2 ...

  4. location.replace与location.href,location.reload的区别

    1. location.replace顾名思义是替换的意思 这种方法的原理是,用新页面的URL替换当前的历史纪录,这样浏览历史记录中就只有一个页面,后  退按钮永远不会变为可用 οnclick=&qu ...

  5. location.reload()和location.replace()的区别与应用

    location.reload()和location.replace()的区别与应用 语法 首先介绍这两个方法的语法 1.reload(): 强迫浏览器刷新当前页面 语法: location.relo ...

  6. window.location对象、window.navigator对象、window.history对象

    location 对象是 window 对象给我们提供了一个location属性用于获取或设置窗体的URL,并且可以用于解析URL.因为这个属性返回的是一个对象,所以我们将这个属性也称为locatio ...

  7. javascript基础——window对象(screen、history、location、navigator、window对象常用方法、window对象常用事件)

    1.screen window.screen 对象包含有关用户屏幕的信息 screen.availWidth 屏幕宽度 screen.availHeight  屏幕高度 2.history forwa ...

  8. 解决安卓微信浏览器中location.reload 或者 location.href失效的问题

    解决安卓微信浏览器中location.reload 或者 location.href失效的问题 参考文章: (1)解决安卓微信浏览器中location.reload 或者 location.href失 ...

  9. location.reload() 和 location.replace()的区别和应用

    首先介绍两个方法的语法: reload 方法,该方法强迫浏览器刷新当前页面. 语法: location.reload([bForceGet])                              ...

最新文章

  1. 普通人学python有用吗 知乎-哪些人更有必要学习python?老男孩教育python
  2. WPF Template模版之DataTemplate与ControlTemplate的关系和应用【二】
  3. HashMap的put方法讲解
  4. php面试题11(边看边复习刚刚讲的)(array_multisort($arr1,$arr2); 用$arr1来排序$arr2。)...
  5. 火狐导cookie文件没反应_效率指南|实操区分FireFox火狐的国内版和国际版
  6. getprofile()获取不到路径_获取链接文件Document——Dynamo Python系列教程(一)
  7. vue 多点触控手势_移动端手势事件(多指操作)
  8. Android学习Matrix对称变换5
  9. 使用 ngrok(小米球)实现内网穿透映像到外网访问项目
  10. 《普林斯顿微积分读本》学习笔记
  11. Mujoco Simulate例子笔记
  12. FusionCompute架构详解
  13. linux进入cbq文件夹,Linux流量控制(SFQ/TBFPRIO/CBQ/HTB原理介绍)
  14. STM32F103RCT6使用HY-SRF05 五针超声波测距模块进行测距实现
  15. 【JY】浅谈混凝土结构/构件性能试验指标概念(二)
  16. MOOC微信小程序开发从入门到实践~笔记
  17. MicrobiomeAnalyst:一款综合的可视化微生物组学数据分析网页工具
  18. elastic-job VS xxl-job
  19. 解决.Net 4.0 A potentially dangerous Request.Form value was detected from the client 异常
  20. 靶机14 DEATHNOTE: 1

热门文章

  1. Debian 陷入尴尬,社区或群龙无首
  2. 查看linux上面是否有安装redis,redis启动
  3. Python奇遇记:数据结构窥探2
  4. 《C和指针》一1.7 问题
  5. highchairs绘图随记
  6. #1045 - Access denied for user 'root'@'localhost' (using password: NO)
  7. 小猿圈web前端之jQuery抽奖系统
  8. 软件架构:5种你应该知道的模式
  9. 表格行与列边框样式处理的原理分析及实战应用
  10. PHP取得json前面有乱码(去除文件头部BOM)