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.