Home > Web Front-end > JS Tutorial > js returns to the previous page and refreshes the code _javascript skills

js returns to the previous page and refreshes the code _javascript skills

WBOY
Release: 2016-05-16 17:45:59
Original
52780 people have browsed it
1: JS reload the page, refresh locally, return to the previous page
Copy the code The code is as follows:

How to write the JS code that returns the first two pages and refreshes them.
Copy code The code is as follows:

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

Two: js method
Copy code The code is as follows:

asp Method to automatically return and refresh:
Copy code The code is as follows:

response.Write(" ")

Generally used to submit an action to a page and then return to the previous page and refresh it!

1. Javascript returns to the previous page history.go(-1), returns two pages: history.go(-2);
2. history.back().
3. window.history .forward() returns to the next page
4. window.history.go (return to which page, you can also use the visited URL)

Example:
Previous page

response.Write("")
response.Write("")
Previous page

Page jump: onclick="window.location.href='list.aspx'"
P.S.
Tips (JS citing JS):

Several ways to refresh the page using Javascript:

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

Methods to automatically refresh the page:
1. Automatically refresh the page: Add the following code to the area

Of which 20 refers to refreshing the page every 20 seconds.

2. Automatic page jump: add the following code to the area

The 20th finger will jump to the http://www.javaeye.com page after 20 seconds

3. The page automatically Refresh the js version


How ASP.NET outputs the 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("")

JS script statement to refresh the frame

//How to refresh the page containing the frame using

(OrRefresh )

//How to refresh the page of another frame using


If you want to refresh when the window is closed or you want to refresh when the window is opened, in < Just call the following statement in body>.

Refresh when opening the window
Refresh when closing




Three: Use JS in ASP to return to the previous page and refresh
Use JS in ASP to return to the previous page and refresh it. I think it is often used when developing websites using ASP. But there are several ways to write it, but the purpose is the same.

Copy code The code is as follows:

<%
response.write("Deleted successfully! font>")
% >

The function implemented by this code is to inform the user that if the implemented function has been achieved, but after returning It is best to refresh the original page so that new information is displayed or deleted items are not displayed. But this code cannot refresh the original web page when returning.
So you need to add this piece of code to the original page:
<script> <br>if(window.name != "Bencalie"){ <br>//If the name attribute of the page is not specified Refresh it with the name <br>location.reload(); <br>window.name = "Bencalie"; <br>} <br>else{ <br>//If the name attribute of the page is the specified name, nothing Do not do it, avoid constant refreshing <br>window.name = ""; <br>} <br></script>

This way we can achieve our goal - return to the top page and refresh.
Of course there is a simpler code than this, response.write"<script>alert('Deletion successful!');window.location='Original page'';</script>"
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template