Home >Web Front-end >JS Tutorial >Summary of commonly used return, automatic jump, refresh, and close statements in JavaScript_javascript skills

Summary of commonly used return, automatic jump, refresh, and close statements in JavaScript_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:20:251600browse

The examples in this article describe the commonly used return, automatic jump, refresh, and close statements in JavaScript. Share it with everyone for your reference. The details are as follows:

1. Javascript Return to the previous page:

Copy code The code is as follows:
history.go(-1)
Return to two pages:
Copy code The code is as follows:
history.go(-2)


2. Back:
Copy code The code is as follows:
history.back()

3. Return to the next page:

Copy code The code is as follows:
window.history.forward()

4. To return to the page, you can also use the visited URL:

Copy the code The code is as follows:
window.history.go(return to location)


Example:
Copy code The code is as follows:


Page jump:
Copy code The code is as follows:
onclick="window.location.href='list.aspx' "


P.S.
Tips (JS citing JS):
Copy code The code is as follows:


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

How to automatically refresh the page:

1. The page automatically refreshes: add the following code to the area

Copy code The code is as follows:

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

2. Automatic page jump: add the following code to the area
Copy code The code is as follows:

Among them, 20 fingers will jump to http://www.jb51.net page
after 20 seconds.
3. The page automatically refreshes the js version
Copy code The code is as follows:


How does ASP.NET output the refresh parent window script statement
1.
Copy code The code is as follows:
this.response.write("<script>opener.location.reload ();</script>");

2.
Copy code The code is as follows:
this.response.write("<script>opener.window.location .href = opener.window.location.href;</script>");


3.
Copy code The code is as follows:
Response.Write("")
JS refresh frame script statement


Copy the code The code is as follows:
//How to refresh the page containing the frame with


Child window refreshes parent window:

Copy code The code is as follows:

Or:
Copy code The code is as follows:
Refresh
How to refresh the page of another frame:


Copy code The code is as follows:


If you want to refresh when the window is closed or when the window is opened, just call the following statement in .

Refresh when opening the window:
Copy code The code is as follows:
Refresh when closed:
Copy code The code is as follows:

Copy code The code is as follows:

JS closes the current page without popping up a JS security reminder


Copy code The code is as follows:

I hope this article will be helpful to everyone’s JavaScript programming design.

Statement:
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
Previous article:Some tips for writing efficient JSLite code imitating JQuery_jqueryNext article:Some tips for writing efficient JSLite code imitating JQuery_jquery

Related articles

See more