This article describes the commonly used return, automatic jump, refresh, and close statements in JavaScript. Share it for your reference. The details are as follows:
1. Javascript returns to the previous page: Copy the code code as follows: history.go(-1) Returns two pages: Copy the code as follows: history.go(-2)
2. Back: Copy the code as follows: history.back()
3. Return to the next page: Copy the code as follows: window.history.forward()
4. Return to which page, you can also use the visited URL: copy the code code as follows: window.history.go (return to location)
example:
Copy the code as follows: <a href="javascript:history.go(-1);">Previous 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);">Previous page</a>
Page jump: Copy the code code as follows: onclick="window.location.href='list.aspx'"
PS
Tips (JS quotes JS):
Copy the 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>
Several ways to refresh a page in 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. Automatic page refresh: add the following code to the <head> area
The code copy is as follows: <meta http-equiv="refresh" content="20">
20 of which refer to refreshing the page every 20 seconds.
2. Automatic page jump: add the following code to the <head> area
The code copy is as follows: <meta http-equiv="refresh" content="20;url=//www.VeVB.COM">
Among them, 20 fingers jump to the //www.VeVB.COM page after 20 seconds
3. Automatic page refresh
Copy the code as follows:<script language="JavaScript">
function myrefresh()
{
window.location.reload();
}
setTimeout('myrefresh()',1000); //Specify refresh once in 1 second
</script>
How to output a refresh parent window script statement
1. Copy the code code as follows: this.response.write("<script>opener.location.reload();</script>");
2. Copy the code code as follows: this.response.write("<script>opener.window.location.href = opener.window.location.href;</script>");
3. Copy the code as follows: Response.Write("<script language=javascript>opener.window.navigate(''The page you want to refresh.asp'');</script>")
JS refresh framework script statement
Copy the code as follows: //How to refresh the page containing the frame
<script language=JavaScript>
parent.location.reload();
</script>
The child window refreshes the parent window:
Copy the code as follows: <script language=JavaScript>
self.opener.location.reload();
</script>
Or: Copy the code as follows: <a href="javascript:opener.location.reload()">Refresh</a>
How to refresh another frame's page with:
Copy the code as follows: <script language=JavaScript>
parent.another FrameID.location.reload();
</script>
If you want to refresh when the window is closed or refresh when the window is opened, just call the following statement in <body>.
Refresh when opening the window: Copy the code code as follows: <body onload="opener.location.reload()">
Refresh when closed: Copy the code code as follows: <body onUnload="opener.location.reload()">
Copy the code as follows:<script language="javascript">
window.opener.document.location.reload()
</script>
JS closes the current page, and does not pop up JS security reminder
Copy the code as follows:<script language="javascript">
window.opener=null;window.open('','_self','');window.close();
</script>
I hope this article will be helpful to everyone's JavaScript programming.