The syntax for the two methods is introduced first:
The reload method, which forces the browser to refresh the current page.
Syntax: Location.reload ([bforceget]) parameter: bforceget, optional parameter, default is False, the current page is taken from the client cache. True, the latest page from the server is taken as a get, equivalent to the client clicking F5 ("Refresh")
The Replace method, which replaces the currently cached item in history (client) by specifying a URL , so you cannot access the URLthat has been replaced by "forward" and "back" after using the Replace method.
Syntax: location.replace (URL) parameter: URL
In the actual application, when re-refresh the page, we usually use: Location.reload () or history.go (0) to do. Because this practice is like the client point F5 Refresh the page, so the page method= "POST", there will be "page expiration" prompt. That's because of the session's security protection mechanism. It can be thought that when the Location.reload () method is called, the ASPX page is already present in the server memory, so it must be IsPostback. If there is such an application: we need to reload the page, which means we expect the page to be re-created on the server and we expect it to be not IsPostback. Here, Location.replace () can complete this task. The Replace page is regenerated on the server each time. You can write this: Location.replace (location.href)
=======================================================
<a onclick= "JAVASCRIPT:WINDOW.LOCATION.HREF=WINDOW.LOCATION.HREF;" >
<a onclick= "Javascript:window.location.reload (); >
Test the same effect. The form was not submitted.
<input type= "Submit" onclick= "Javascript:window.location.reload ()" value= "click" id= "Btnvcode"/>
<input type= "Submit" onclick= "JAVASCRIPT:WINDOW.LOCATION.HREF=WINDOW.LOCATION.HREF; value=" click "id=" BtnVCode "/ >
Both submit data
Window.location.Reload () should be refreshed. (If there is data submitted, will be prompted whether to submit (yes and no option))
Window.location.href=window.location.href; is a directed URL submission data
It is best not to use Location.reload (), and Location=location is better, and in the modal window (ShowModalDialog and showModelessDialog) The former can not be used.
Reload parameter has true and false, is it more interesting?
Avoid repeating commits:
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.ra Ndom ());location=location; \ "> Selection guide book </a>";
}
Else
{
String t = (viewstate["state"). ToString () = = "Query" | | ((DataRowView) e.item.dataitem). row["Gzzt"]. ToString () = = "End of work")? "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 () and Window.location.href window.location.Reload () should be refreshed. ( If there is data submitted, will be prompted whether to submit (yes and no option))
Window.location.href=window.location.href;
is a directed URL submission data
Is it a big difference or is it a matter of submitting data?
function Refresh ()
{
Refresh page Functions
Window.focus (); Refresh window
Document.execcommand ("refresh"); Refresh window
Self.location.reload (); Refresh the current window
Parent.location.reload (); Refresh parent window
Aaa.location.reload (); pop-up window refreshes parent window
}
Use Window.location.replace () or window.location.href () to reload this page without a prompt box
Window.location.Reload () and window.location.href difference (RPM)