学堂 学堂 学堂公众号手机端

window.location.Reload()和window…

lewis 1年前 (2024-04-20) 阅读数 20 #技术
<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();
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.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(), 来重新加载此页面不出现提示框

版权声明

本文仅代表作者观点,不代表博信信息网立场。

热门