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

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 onclick="javascript:window.location.href=window.location.href;">

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

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

<input type="submit" onclick="javascript:window.location.reload();" value="单击" id="btnVCode" />
<input type="submit" onclick="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='#' onclick=\"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='#' onclick=\"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.loc ...

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

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

  3. window.location.reload();页面实现跳转和刷新

    1 history.go(0)2 location.reload()3 location=location4 location.assign(location)5 document.execComma ...

  4. JavaScript BOM-11-BOM的核心-window对象; window对象的控制,弹出窗口方法; 超时调用; 间歇调用; location对象常用属性; 位置操作--location.reaplace,location.reload(); BOM中的history对象; Screen对象及其常用属性; Navigator对象;

    JavaScript BOM 学习目标 1.掌握什么是BOM 2.掌握BOM的核心-window对象 3.掌握window对象的控制.弹出窗口方法 什么是bom BOM(browser object ...

  5. javascript:location.reload()和location.replace()的区别,及对图片缓存的影响。

    有段时间没有清理IE的临时文件(缓存文件),在我清理的时候,我突然发现一个问题. 我打开的一个网站,图片默认缓存一个月的,但我发现,当我上传图片或删除图片之后,图片重新缓存,也就意味着,在我上传新图片 ...

  6. 打开子页面及刷新父页面 window.open window.opener.reload()

    //打开子页面 var url=children_url;window.open(url) //刷新parent页面 var url=parent_urlfunction refresh(url){  ...

  7. window.location.href和window.open的几种用法和区别

    使用js的同学一定知道js的location.href的作用是什么,但是在js中关于location.href的用法究竟有哪几种,究竟有哪些区别,估计很多人都不知道了. 一.location.href ...

  8. window.location.href = window.location.href window.location.reload()

    w 0-会议预订提交了预订日期,预订成功后默认显示仅显示当前日期的新页面若显示预定日的信息,则可以对预定日存入cookie: http://stackoverflow.com/questions/24 ...

  9. window.location.assign和window.location.href区别

    window.location.assign和window.location.href区别 window.location.assign(url)和window.location.href=url实现 ...

随机推荐

  1. 单源最短路径-Dijkstra算法

    1.算法标签 贪心 2.算法描述 具体的算法描述网上有好多,我觉得莫过于直接wiki,只说明一些我之前比较迷惑的. 对于Dijkstra算法,最重要的是维护以下几个数据结构: 顶点集合S : 表示已经 ...

  2. 非阻塞式socket的select()用法

    Select在Socket编程中还是比较重要的,可是对于初学Socket的人来说都不太爱用Select写程序,他们只 是习惯写诸如 connect.accept.recv或recvfrom这样的阻塞程 ...

  3. SpriteParticle II

    [SpriteParticle II] 1.Randomizing the Starting Position 2.Setting the Initial Angle 3.Setting a Part ...

  4. logstash开源日志收集查询分析系统

    http://storysky.blog.51cto.com/628458/1158707/ http://www.logstash.net/ http://blog.sina.com.cn/s/bl ...

  5. Objective-C 学习记录6--dictionary

    1.NSDictionary 和NSMutableDictionary NSDictionary dictionaryWithObjectsAndKeys:~,nil 使用键值对创建字典,用nil标志 ...

  6. SNMP MIB中的含read-create节点的表的实现

    做过snmp/mib开发的知道,常见的节点类型一般只有no-accessible,read-only,read-write三种访问类型.snmp V2中引入了一种新的访问类型:read-create. ...

  7. (C#)使用队列(Queue)解决简单的并发问题

    (C#)使用队列(Queue)解决简单的并发问题 2015-07-16 13:04 13265人阅读 评论(8) 收藏 举报  分类: Asp.Net(8)  版权声明:本文为博主原创文章,未经博主允 ...

  8. 详解文件操作(ifstream、ofstream、fstream)[转]

    C++ 通过以下几个类支持文件的输入输出: ofstream: 写操作(输出)的文件类 (由ostream引申而来) ifstream: 读操作(输入)的文件类(由istream引申而来) fstre ...

  9. NodeJs使用Mysql模块实现事务处理

    依赖模块: 1. mysql:https://github.com/felixge/node-mysql npm install mysql --save 2. async:https://githu ...

  10. udt nat traverse

    https://github.com/bakwc/udt-nat-traverse Example of nat traversal using udt library. UDT is a udp b ...