Js returns to the previous page and refreshes the code

Source: Internet
Author: User

I. JS: Reload the page, refresh locally, and return to the previous page.
Copy codeThe Code is as follows:
<A href = "javascript: history. go (-1)"> return to the previous page </a>
<A href = "javascript: location. reload ()"> reload the page and refresh it locally </a>
<A href = "javascript: history. go (-1); location. reload ()"> return to the reload page of the previous page and refresh the page locally </a>

Return the first two pages and refresh the JS Code.
Copy codeThe Code is as follows:
History. go (-2 );
Location. reload ();

Ii. js method
Copy codeThe Code is as follows:
<A href = "#" onclick = "self. location = document. referrer;"> return </a>

Methods for asp to automatically return and refresh:
Copy codeThe Code is as follows:
Response. Write ("<script language = javascript> self. location = document. referrer; </script> ")

It is generally used to submit an action to a page and return to the previous page and refresh it!
3. Use JS in ASP to return to the previous page and refresh the page
In ASP, JS is used to return to the previous page and refresh the page. I think it is often used to develop websites using ASP. But there are also several writing methods, but the purpose is the same.
Copy codeThe Code is as follows:
<%
Response. write ("<font color =" red "" font-size = "" 12px ""> 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, it is best to refresh the original page to display new information or make the deleted items not displayed. However, this code cannot refresh the original webpage when it returns.
Therefore, you need to add the following code to the original page:
<Script>
If (window. name! = "Bencalie "){
// Refresh the page if its name attribute is not the specified name
Location. reload ();
Window. name = "Bencalie ";
}
Else {
// If the name attribute of the page is the specified name, nothing will be done, avoiding constant refresh.
Window. name = "";
}
</Script>

In this way, we can achieve our goal-return to the previous page and refresh it.
Of course there is more simple code than this, response. write "<script> alert ('deleted successfully! '); Window. location = 'original page'; </script>"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.