Seven methods of refreshing frame subpages in js
The following uses three pages named framedemo.html, top.html, button.html as an example to explain how to do it in detail.
Framedemo.html consists of two pages, the upper and lower pages, and the code is as follows:
frameDemo Now assuming that top.html, the page above, has a button to refresh the page below, you can use the following seven methods It's up to you to decide which one of these statements is easier to use.
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();
Explanation:
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 an array. Represents all subpages within the frame.
4.item is the 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.
top.html source code; (There are seven buttons on the page, the functions of which are to refresh the frame page below)