JS Local refresh returns previous page code

  • 2021-07-04 18:12:52
  • OfStack

To make a long story short, today introduce a method to realize this function. Friends who need to know can refer to the following:

1. JS overloads the page, refreshes locally, and returns to the previous page
The code is as follows:


<a href="javascript:history.go(-1)"> Back up 1 Page </a> 
<a href="javascript:location.reload()"> Overload page, refresh locally </a> 
<a href="javascript:history.go(-1);location.reload()"> Back up 1 Page overload page, local refresh </a> 

Go back to the first 2 pages and refresh the JS code.
The code is as follows:

history.go(-2);
location.reload();

2. js method

The code is as follows:

< a href="#" onclick="self.location=document.referrer;" > Return < /a >

asp automatic return and refresh method:

The code is as follows:

response.Write(" < script language=javascript > self.location=document.referrer; < /script > ")

1 is used to submit action to 1 page and return to the previous 1 page and refresh!
1. Javascript returns the previous page history. go (-1) and two pages: history. go (-2);
2.history.back().
3. window. history. forward () returns to the next page
4. window. history. go (Go back to page, and you can also use visited URL)

Example:


<a href="javascript:history.go(-1);"> Up 1 Page </a>

response.Write("<script language=javascript>")
response.Write("if(!confirm(' Complete a task ?')){history.back();}")
response.Write("</script>")
response.Write("<script language=javascript>history.go(-1);</script>")

<a href="javascript:history.go(-1);"> Up 1 Page </a>

 Page jump :onclick="window.location.href='list.aspx'"

P.S.
Tip (JS references JS):


<script type=text/javascript>
<!--
if (typeof SWFObject == "undefined") {
document.write('<scr' + 'ipt type="text/javascript" src="/scripts/swfobject-1.5.js"></scr' + 'ipt>');}
//-->
</script>

Javascript Several ways to refresh pages:

1 history.go(0)
2 location.reload()
3 location=location
4 location.assign(location)
5 document.execCommand('Refresh')
6 window.navigate(location)
7 location.replace(location)
8 document.URL=location.href

How to refresh the page automatically:
1. Automatic page refresh: Add the following code to the area

< meta http-equiv="refresh" content="20" >

Among them, 20 refers to refreshing the page every 20 seconds.

2. Automatic page jump: Add the following code < head > In the region

< meta http-equiv="refresh" content="20;url=http://chenhaoxiang.github.io" >

Among them, 20 fingers jump to the page of http://chenhaoxiang.github.io after 20 seconds

3. Page automatically refreshes js version


<script language="JavaScript">
function myrefresh()
{
 window.location.reload();
}
setTimeout('myrefresh()',1000); // Specify 1 Second refresh 1 Times 
</script>

ASP. NET How to Output Refresh Parent Window Script Statement

1. this.response.write(" < script > opener.location.reload(); < /script > ");
2. this.response.write(" < script > opener.window.location.href = opener.window.location.href; < /script > ");
3. Response.Write(" < script language=javascript > opener. window. navigate (''Page you want to refresh. asp''); < /script > ")

Script statement for JS refresh framework


// How to refresh the page containing the frame with the 
<script language=JavaScript>
 parent.location.reload();
</script>

// Child window refreshes parent window 
<script language=JavaScript>
 self.opener.location.reload();
</script>
( Or <a href="javascript:opener.location.reload()"> Refresh </a> )

// How to refresh another 1 Use for pages of a frame 
<script language=JavaScript>
 parent. Another 1FrameID.location.reload();
</script>

If you want to refresh when you close the window or when you want to open the window, you can call the following statement in.


<body onload="opener.location.reload()">  Refresh on window opening 
<body onUnload="opener.location.reload()">  Refresh on closing 

<script language="javascript">
window.opener.document.location.reload()
</script>

3. Use JS to return to the previous page and refresh it in ASP
In ASP using JS to return to the previous page and refresh I think is the use of ASP when developing websites often used. But there are several ways of writing, but the purpose is one.

The code is as follows:


<% 
response.write("<font color=""red"" font-size=""12px""> Has been deleted successfully! font>") 
%> 
<div align="center">[<a href="/"onClick="javascript :window.history.go(-1);return false;" class=fontsize14><span style="color: #CC0033"> Return </span></a>]</div>

The function of this code is to inform the user that if the function has been achieved, but it is best to refresh the original page under 1 to show new information or let the deleted things not show. However, this code can't refresh the original web page when it returns.
So you need to add this code to the original page:


<script> 
if(window.name != "Bencalie"){ 
// If the  name  Refreshes the property if it is not the specified name  
location.reload(); 
window.name = "Bencalie"; 
} 
else{ 
// If the  name  If the attribute is the specified name, do nothing to avoid constant refreshing 
window.name = ""; 
} 
</script>

In this way, we can achieve our goal. Go back to the previous page and refresh.
Of course, there is also simpler code than this.

response.write(" < script > alert ('Delete succeeded! '); window. location= 'original page '; < /script > ");


Related articles: