Home > Web Front-end > JS Tutorial > A brief analysis of other pages in the JS refresh frame && Summary of JS refresh window methods_javascript skills

A brief analysis of other pages in the JS refresh frame && Summary of JS refresh window methods_javascript skills

WBOY
Release: 2016-05-16 17:29:32
Original
821 people have browsed it
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:
Copy code The code is as follows:


< HTML >
< ; HEAD >
< TITLE > frame

< frameset rows ="50%,50%" >
< frame name =top src ="top.html" >
< frame name =bottom src ="bottom.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:
Copy code The code is as follows:


< HTML >
< HEAD >
< TITLE > top.html

< 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 >



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:
Copy code Code As follows:


< HTML >
< HEAD >
< TITLE > bottom.html

< BODY onload ="alert('I've been loaded!')" >
< h1 > This is the content in bottom.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("");
3.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

( OrRefresh )
/ /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.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template