window.location.Reload()和window.location.href 区别
首先介绍两个方法的语法:
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 区别的更多相关文章
- window.location.reload(false);window.location.reload(true);history.Go(0)区别
在日常工作中常用的页面刷新方式的区别: 1 window.location.reload(false); 先说说window.location.reload(false);当我们window.loc ...
- js 刷新页面window.location.reload();
Javascript刷新页面的几种方法:1 history.go(0)2 window.location.reload() window.location.reload(true) 3 ...
- window.location.reload();页面实现跳转和刷新
1 history.go(0)2 location.reload()3 location=location4 location.assign(location)5 document.execComma ...
- 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 ...
- javascript:location.reload()和location.replace()的区别,及对图片缓存的影响。
有段时间没有清理IE的临时文件(缓存文件),在我清理的时候,我突然发现一个问题. 我打开的一个网站,图片默认缓存一个月的,但我发现,当我上传图片或删除图片之后,图片重新缓存,也就意味着,在我上传新图片 ...
- 打开子页面及刷新父页面 window.open window.opener.reload()
//打开子页面 var url=children_url;window.open(url) //刷新parent页面 var url=parent_urlfunction refresh(url){ ...
- window.location.href和window.open的几种用法和区别
使用js的同学一定知道js的location.href的作用是什么,但是在js中关于location.href的用法究竟有哪几种,究竟有哪些区别,估计很多人都不知道了. 一.location.href ...
- window.location.href = window.location.href window.location.reload()
w 0-会议预订提交了预订日期,预订成功后默认显示仅显示当前日期的新页面若显示预定日的信息,则可以对预定日存入cookie: http://stackoverflow.com/questions/24 ...
- window.location.assign和window.location.href区别
window.location.assign和window.location.href区别 window.location.assign(url)和window.location.href=url实现 ...
随机推荐
- Flex3.0 Loader类的练习
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="h ...
- 如何开启php报错
今天碰到一个很二的问题,安装了php网站之后,发现nginx一直无法解析到index.php文件,显示为空白,从后台的日志来看是500错误,但是同目录下的phpinfo.php却可以正常解析.想来应该 ...
- Hadoop2.3+Hive0.12集群部署
0 机器说明 IP Role 192.168.1.106 NameNode.DataNode.NodeManager.ResourceManager 192.168.1.107 Secondary ...
- Uva 10007 / HDU 1131 - Count the Trees (卡特兰数)
Count the Trees Another common social inability is known as ACM (Abnormally Compulsive Meditation) ...
- WebBrowser的各种使用方法(未完待续)(XE8+WIN7)
相关资料: 占时想不起来了,有时间我补上吧. 程序下载: http://download.csdn.net/detail/zhujianqiangqq/9666390 实例代码: unit Unit1 ...
- resharper 7.x 注册码key
user:dobit sn:G/YgFyekI7EL0oBc5YBWKI5WCi3pwXWP
- oracle学习 十 数据库的语句优化(持续更)
平时关注Oracle数据库的网友都知道,Oracle性能优化保证了Oracle数据库的健壮性.下面就此提出需要注意的两个原则. 原则一:注意WHERE子句中的连接顺序: ORACLE采用自下而上的 ...
- defaultAutoCommit
driver default The default auto-commit state of connections created by this pool. If not set then th ...
- json操作json类型转换
前提是需要加Jar包: gson-2.2.2.jar package utils; import java.io.BufferedReader;import java.io.FileInputStre ...
- XSLT模糊查询函数contains不区分大小写,for-each排序
代码如下: <xsl:for-each select="//NewDataSet/map/area[contains(translate(@alt, 'ABCDEFGHIJKLMNOP ...