JS Refresh Page Method Daquan \js Seven ways to refresh frame subpages __div

Source: Internet
Author: User

Let's look at a simple example:
The following three pages are named Frame.html, top.html, bottom.html as examples to specify how to do.
Frame.html consists of two pages (bottom.html) on top (top.html) with the following code:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<TITLE> Frame </TITLE>
</HEAD>
<frameset rows= "50%,50%" >
<frame name=top src= "top.html" >
<frame name=bottom src= "bottom.html" >
</frameset>
</HTML>
Now assume that top.html (that is, the page above) has seven button to achieve the bottom.html (that is, the following page) of the refresh, you can use the following seven kinds of statements, which easy to do with their own.
Statement 1. Window.parent.frames[1].location.reload ();
Statement 2. Window.parent.frames.bottom.location.reload ();
Statement 3. window.parent.frames["Bottom"].location.reload ();
Statement 4. Window.parent.frames.item (1). Location.reload ();
Statement 5. Window.parent.frames.item (' Bottom '). Location.reload ();
Statement 6. Window.parent.bottom.location.reload ();
Statement 7. window.parent[' Bottom '].location.reload ();
The code for the Top.html page is as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<TITLE> top.html </TITLE>
</HEAD>
<BODY>
<input Type=button value= "Refresh 1" onclick= "Window.parent.frames[1].location.reload ()" ><br>
<input Type=button value= "Refresh 2" onclick= "Window.parent.frames.bottom.location.reload ()" ><br>
<input Type=button value= "Refresh 3" onclick= "window.parent.frames[' Bottom '].location.reload ' ()" ><br>
<input Type=button value= "Refresh 4" onclick= "Window.parent.frames.item (1). Location.reload ()" ><br>
<input Type=button value= "Refresh 5" onclick= "Window.parent.frames.item (' Bottom '). Location.reload ()" ><br>
<input Type=button value= "Refresh 6" onclick= "Window.parent.bottom.location.reload ()" ><br>
<input Type=button value= "Refresh 7" onclick= "window.parent[' Bottom '].location.reload ' ()" ><br>
</BODY>
</HTML>
The following is the bottom.html page source code, in order to prove that the bottom page is indeed refreshed, after loading the page pop-up a dialog box.
The code for the Bottom.html page is as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<TITLE> bottom.html </TITLE>
</HEAD>
<body onload= "alert (' I was loaded. ') ' >
</BODY>
</HTML>

Explain:
1.window refers to the current page, for example, for this example, it refers to the top.html page.
2.parent refers to the parent page of the current page, which is the frame page that contains it. For example, for this example, it refers to framedemo.html.
3.frames is a Window object and is an array. Represents all the subpages within the frame.
4.item is the method. Returns the elements inside an array.
5. If the child page is also a frames page, inside or other sub pages, then some of the above methods may not work.
Report:
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 <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 <meta http-equiv= "Refresh" content= "20;url=http://www.wyxg.com" >
20 of which refers to 20 seconds after the jump to the http://www.wyxg.com page
3. Page automatically refresh JS version
<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. This.response.write ("<script>opener.location.reload ();</script>");
2. This.response.write ("<script>opener.window.location.href = opener.window.location.href;</script>") ;
3. Response.Write ("<script language=javascript>opener.window.navigate (" You want to refresh the page. asp ');</script> ")
JS Refresh Frame Script statement
How to refresh the page that contains the frame with
<script language=javascript>
Parent.location.reload ();
</script>
child window refreshes parent window
<script language=javascript>
Self.opener.location.reload ();
</script>
(or <a href= "javascript:opener.location.reload ()" > Refresh </a>)
How to refresh another frame's page with
<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>.
<body onload= "Opener.location.reload ()" > Refresh when opening windows
<body onunload= "Opener.location.reload ()" > Refresh when closed
<script language= "JavaScript" >
Window.opener.document.location.reload ()
</script>

This article comes from: Script House (www.jb51.net) Detailed source reference: http://www.jb51.net/article/14397.htm

Here are three pages named framedemo.html,left.html,right.html as an example to specify how to do this.

Framedemo.html consists of about two pages, the code is as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<TITLE> Framedemo </TITLE>
</HEAD>
<frameset cols= "200,*" >
<frame name=top src= "left.html" >
<frame Name=button src= "right.html" >
</frameset>
</HTML>

Now assume that left.html that the above page has a button to achieve the following page refresh, you can use the following seven kinds of statements, which easy to do with their own.

Statement 1. Window.parent.frames[1].location.reload ();

Statement 2. Window.parent.frames.bottom.location.reload ();

Statement 3. window.parent.frames["Bottom"].location.reload ();

Statement 4. Window.parent.frames.item (1). Location.reload ();

Statement 5. Window.parent.frames.item (' Bottom '). Location.reload ();

Statement 6. Window.parent.bottom.location.reload ();

Statement 7. window.parent[' Bottom '].location.reload ();

Explain:

1.window refers to the current page, for example, for this example, it refers to the top.html page.

2.parent refers to the parent page of the current page, which is the frame page that contains it. For example, for this example, it refers to framedemo.html.

3.frames is a Window object and is an array. Represents all the subpages within the frame.

4.item is the method. Returns the elements inside an array.

5. If the child page is also a frames page, inside or other sub pages, then some of the above methods may not work.
top.html source code; (There are seven buttons on the page, the function is to refresh the frames page below)

<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
</HEAD>
<BODY>
<input Type=button value= "Refresh 1" onclick= "Window.parent.frames[1].location.reload ()" ><br>
<input Type=button value= "Refresh 2" onclick= "Window.parent.frames.bottom.location.reload ()" ><br>
<input Type=button value= "Refresh 3" onclick= "window.parent.frames[' Bottom '].location.reload ' ()" ><br>
<input Type=button value= "Refresh 4" onclick= "Window.parent.frames.item (1). Location.reload ()" ><br>
<input Type=button value= "Refresh 5" onclick= "Window.parent.frames.item (' Bottom '). Location.reload ()" ><br>
<input Type=button value= "Refresh 6" onclick= "Window.parent.bottom.location.reload ()" ><br>
<input Type=button value= "Refresh 7" onclick= "window.parent[' Bottom '].location.reload ' ()" ><br>
</BODY>
</HTML>

The following is the right.html page source code, in order to prove that the bottom page is indeed refreshed, after loading the page pop-up a dialog box.

<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
</HEAD>
<body onload= "alert (' I was loaded. ') ' >
</BODY>
</HTML>

After my test, only 1 and 4 show the effect, the other seems wrong yo
============================

Report:
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 <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 <meta http-equiv= "Refresh" content= "20;url=http://www.wyxg.com" >
20 of which refers to 20 seconds after the jump to the http://www.wyxg.com page

3. Page automatically refresh JS version
<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. This.response.write ("<script>opener.location.reload ();</script>");

2. This.response.write ("<script>opener.window.location.href = opener.window.location.href;</script>") ;

3. Response.Write ("<script language=javascript>opener.window.navigate (" You want to refresh the page. asp ');</script> ")


JS Refresh Frame Script statement

How to refresh the page that contains the frame with
<script language=javascript>
Parent.location.reload ();
</script>

child window refreshes parent window
<script language=javascript>
Self.opener.location.reload ();
</script>
(or <a href= "javascript:opener.location.reload ()" > Refresh </a>)

How to refresh another frame's page with
<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>.

<body > Refresh when opening windows
<body > Refresh at shutdown

<script language= "JavaScript" >
Window.opener.document.location.reload ()
</script>

Http://www.blogjava.net/zzzlyr/archive/2009/05/22/277424.html

Http://www.jb51.net/article/14397.htm

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.