The examples in this article describe the common JavaScript return, automatic jump, refresh, and closing statements. Share to everyone for your reference. Specifically as follows:
1. Javascript returns to the previous page:
Copy Code code as follows:
Return two pages:
Copy Code code as follows:
2. Back:
Copy Code code as follows:
3. Return to the next page:
Copy Code code as follows:
Window.history.forward ()
4. Return to page, or use the URL you have visited:
Copy Code code as follows:
Window.history.go (return position)
Cases:
Copy Code code as follows:
<a href= "Javascript:history.go (-1);" > Up one page </a>
Response. Write ("<script language=javascript>")
Response. Write ("If" (!confirm (' Complete task? ')) {History.back ();} ")
Response. Write ("</script>")
Response. Write ("<script language=javascript>history.go ( -1);</script>")
<a href= "Javascript:history.go (-1);" > Up one page </a>
Page Jump:
Copy Code code as follows:
onclick= "window.location.href= ' list.aspx '"
P.S.
Tips (JS reference js):
Copy Code code as follows:
<script type=text/javascript>
<!--
if (typeof swfobject = = "undefined") {
document.write (' <scr ' + ' IPT type= "Text/javascript" src= "/scripts/swfobject-1.5.js" ></scr ' + ' ipt> ');}
-->
</script>
JavaScript refreshes the page in several ways:
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
Ways to automatically refresh pages:
1. Page Automatic refresh: Add the following code to the
Copy Code code as follows:
<meta http-equiv= "Refresh" content= ">"
20 of which means that the page is refreshed every 20 seconds.
2. Page Automatic Jump: Add the following code to the
Copy Code code as follows:
<meta http-equiv= "Refresh" content= "20;url=http://www.jb51.net" >
20 of which refers to 20 seconds after the jump to the Http://www.jb51.net page
3. Page automatically refresh JS version
Copy Code code as follows:
<script language= "JavaScript" >
function Myrefresh ()
{
Window.location.reload ();
}
SetTimeout (' Myrefresh () ', 1000); Specify 1 seconds to refresh once
</script>
Asp. NET how to output refresh the parent window script statement
1.
Copy Code code as follows:
This.response.write ("<script>opener.location.reload ();</script>");
2.
Copy Code code as follows:
This.response.write ("<script>opener.window.location.href = opener.window.location.href;</script>");
3.
Copy Code code as follows:
Response.Write ("<script language=javascript>opener.window.navigate (" You want to refresh the page. asp ');</script> ")
JS Refresh Frame Script statement
Copy Code code as follows:
How to refresh the page that contains the frame with
<script language=javascript>
Parent.location.reload ();
</script>
child window refreshes the parent window:
Copy Code code as follows:
<script language=javascript>
Self.opener.location.reload ();
</script>
Or:
Copy Code code as follows:
<a href= "Javascript:opener.location.reload ()" > Refresh </a>
How to refresh the page for another frame:
Copy Code code as follows:
<script language=javascript>
Parent. Another FrameID.location.reload ();
</script>
If you want to close the window or refresh when you want to open windows, call the following statement in <body>.
Refresh when opening window:
Copy Code code as follows:
<body onload= "Opener.location.reload ()" >
Refresh at shutdown:
Copy Code code as follows:
<body onunload= "Opener.location.reload ()" >
Copy Code code as follows:
<script language= "JavaScript" >
Window.opener.document.location.reload ()
</script>
JS closes the current page, does not eject the JS security reminder
Copy Code code as follows:
<script language= "JavaScript" >
Window.opener=null;window.open (', ' _self ', '); Window.close ();
</script>
I hope this article will help you with your JavaScript programming.