The following example uses the three pages separated by frame.html?top.html?bottom.html to describe how to do this.
Frame.html consists of two pages (bottom (bottom.html) under top.html,CodeAs follows:
-
- <! 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>
<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en"> <HTML>
Now, let's assume that top.html (the page above) has seven buttoners to refresh bottom.html (the page below). You can use the following seven statements to see which one is easy to use.
Reference 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>
-
- Below is the bottom.html pageSource codeTo verify that the page below is refreshed, a dialog box is displayed after loading.
-
- 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 got loaded! ')">
-
- <H1> this is the content in bottom.html.
-
- </Body>
-
<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en"> <HTML>
Explanations:
- Windowless refers to the front page. For example, this refers to the top.html page.
- Parent refers to the parent page of the current page, that is, the framework page containing it. In this example, framedemo.html is used.
- Frames is a window object and an array. Represents all the child pages in the framework.
- Item is a method. Returns the elements in the array.
- If the sub-page is also a frame page and contains other sub-pages, some of the above methods may not work.
Appendix:
How to refresh the page with javascript:
- History. Go (0)
- Location. Reload ()
- Location = Location
- Location. Assign (location)
- Document.exe ccommand ('refresh ')
- Window. navigate (location)
- Location. Replace (location)
- Document. url = location. href
How to automatically refresh the page:
1. Automatically refresh the page: Add the following code to the <Meta http-equiv = "refresh" content = "20">
20 indicates refreshing the page every 20 seconds.
2. automatic page Jump: Add the following code to the <Meta http-equiv = "refresh" content = "20; url = http://www.wyxg.com">
20 means jump to the http://www.wyxg.com page every 20 seconds
3. Automatically refresh JS version on the page
<Script language = "JavaScript">
Function myrefresh ()
{
Window. Location. Reload ();
}
SetTimeout ('myrefresh () ', 1000); // refresh once per second
</SCRIPT>
JS refresh framework script statement
// How to refresh the page containing the framework
<Script language = JavaScript>
Parent. Location. Reload ();
</SCRIPT>
// Refresh the parent window in the Child Window
<Script language = JavaScript>
Self. opener. Location. Reload ();
</SCRIPT>
(Or <a href = "javascript: opener. Location. Reload ()"> refresh </a>)
// How to refresh the page of another framework
<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>.
<Body onload = "opener. Location. Reload ()"> refresh when opening a window
<Body onUnload = "opener. Location. Reload ()"> refresh when disabled