Seven methods of js refreshing frame subpage code_javascript skills
WBOY
Release: 2016-05-16 18:58:26
Original
1077 people have browsed it
The following uses three pages named framedemo.html, top.html, button.html as an example to explain how to do this. The framedemo.html consists of two pages, the upper and lower pages. The code is as follows:
Now assume that top.html is the page above There is a button to refresh the page below. You can use the following seven statements. It is up to you which one 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() ; 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. top.html source code; (There are seven buttons on the page, their functions are to refresh the frame page below)
The following is the bottom.html page source code. In order to prove that the page below has indeed been refreshed, a dialog box pops up after the page is loaded.
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