Let’s look at a simple example first:
The following takes three pages named frame.html, top.html, and bottom.html as an example to explain how to do it.
frame.html consists of two pages: top (top.html) and bottom (bottom.html). The code is as follows:
< 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 (i.e. the page above) has seven buttons to refresh bottom.html (i.e. the page below). You can use the following seven statements. Which one is better for you to see? Done.
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 of top.html page is as follows:
< 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 page below has indeed been refreshed, a dialog box will pop up after the page is loaded. The code for the
bottom.html page is as follows:
< HTML >
< HEAD >
< TITLE > bottom.html TITLE >
HEAD >
< BODY onload ="alert('I've been loaded!')" >
< h1 > This is the content in bottom.html. h1 >
BODY >
HTML >
Explain:
1.window refers to the current page, for example, in this example it refers to the top.html page.
2.parent refers to the parent page of the current page, that is, the frame page containing it. For example, for this example it refers to framedemo.html.
3.frames is a window object and an array. Represents all subpages within the frame.
4.item is a method. Returns the elements in the array.
5. If the subpage is also a frame page with other subpages inside, then some of the above methods may not work.
Attachment:
Several ways to refresh the page using 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 area
The 20 refers to refreshing the page every 20 seconds.
2. The page automatically jumps: add the following code to the area中
The 20th finger will jump to http:// after 20 seconds. www.jb51.net page
3. The page automatically refreshes js version
How does ASP.NET output the refresh parent window script statement?
1.this.response.write("<script>opener.location.reload();</script>");
2.this.response.write("")
JS script statement to refresh the frame
//How to refresh the page containing the frame using
< ;script language=JavaScript>
parent.location.reload();
//The child window refreshes the parent window
( Or
Refresh )
/ /How to refresh the page of another frame using
If you want If you want to refresh when the window is closed or want to refresh when the window is opened, just call the following statement in .
Refresh when opening the window
Refresh when closing
Add onUnload to the BODY of the pop-up window ="window.opener.location.reload();" Closing the pop-up window will automatically refresh the parent window.