Common JavaScript return, automatic jump, refresh, close statement summary, and javascript automatic jump

Source: Internet
Author: User

Common JavaScript return, automatic jump, refresh, close statement summary, and javascript automatic jump

This example describes common JavaScript return, automatic jump, refresh, and close statements. Share it with you for your reference. The details are as follows:

1. Javascript returns the previous page:Copy codeThe Code is as follows: history. go (-1) returns two pages:Copy codeThe Code is as follows: history. go (-2)

2. Backward:Copy codeThe Code is as follows: history. back ()

3. The next page is returned:Copy codeThe Code is as follows: window. history. forward ()

4. Return the page number. You can also use the accessed URL:Copy codeThe Code is as follows: window. history. go (return position)

Example:
Copy codeThe Code is as follows: <a href = "javascript: history. go (-1);"> previous page </a>

Response. Write ("<script language = javascript> ")
Response. Write ("if (! Confirm ('finish the task? ') {History. back ();}")
Response. Write ("</script> ")
Response. Write ("<script language = javascript> history. go (-1); </script> ")
<A href = "javascript: history. go (-1);"> previous page </a>

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

P.S.
Tips (JS reference JS ):
Copy codeThe Code is as follows: <script type = text/javascript>
<! --
If (typeof SWFObject = "undefined "){
Document. write ('<scr' + 'iptype = "text/javascript" src = "/scripts/swfobject-1.5.js"> </scr '+ 'ipt'> ');}
// -->
</Script>

How to refresh the page with Javascript:
1 history. go (0)
2 location. reload ()
3 location = location
4 location. assign (location)
5 document.exe cCommand ('refresh ')
6 window. navigate (location)
7 location. replace (location)
8 document. URL = location. href

How to automatically refresh the page:

1. Automatically refresh the page: Add the following code to the Copy codeThe Code is as follows: <meta http-equiv = "refresh" content = "20">
20 indicates refreshing the page every 20 seconds.

2. automatic page Jump: Add the following code to the Copy codeThe Code is as follows: <meta http-equiv = "refresh" content = "20; url = http://www.bkjia.com">
20 means jump to the http://www.bkjia.com page every 20 seconds

3. Automatically refresh js version on the page
Copy codeThe Code is as follows: <script language = "JavaScript">
Function myrefresh ()
{
Window. location. reload ();
}
SetTimeout ('myrefresh () ', 1000); // refresh once per second
</Script>

How does ASP. NET output the script statement for refreshing the parent window?
1.Copy codeThe Code is as follows: this. response. write ("<script> opener. location. reload (); </script> ");

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


3.Copy codeThe Code is as follows: Response. Write ("<script language = javascript> opener. window. navigate (''page you want to refresh. asp''); </script> ")

JS refresh framework script statement
Copy codeThe Code is as follows: // how to refresh the page containing the framework
<Script language = JavaScript>
Parent. location. reload ();
</Script>

Child Window refresh parent window:
Copy codeThe Code is as follows: <script language = JavaScript>
Self. opener. location. reload ();
</Script>
Or:Copy codeThe Code is as follows: <a href = "javascript: opener. location. reload ()"> refresh </a>

How to refresh the page of another framework:
Copy codeThe Code is as follows: <script language = JavaScript>
Parent. Another FrameID. location. reload ();
</Script>

If you want to refresh the window when closing the window or refresh the window when opening the window, you can call the following statement in <body>.

Refresh when opening the window:Copy codeThe Code is as follows: <body onload = "opener. location. reload ()">
Refresh when closing:Copy codeThe Code is as follows: <body onUnload = "opener. location. reload ()">
Copy codeThe Code is as follows: <script language = "javascript">
Zookeeper opener.doc ument. location. reload ()
</Script>

Close the current page with JS Security reminder not displayed
Copy codeThe Code is as follows: <script language = "javascript">
Window. opener = null; window. open ('', '_ self',''); window. close ();
</Script>

I hope this article will help you design javascript programs.

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.