The framework of the refresh has always been uncertain, now think of this problem, the solution is really quite a lot, here summed up the 7 ways to refresh the frame with JS, in any of the frames page to refresh the other frames page, or more practical, these 7 methods are:
Method 1. Window.parent.frames[1].location.reload ();
Method 2. Window.parent.frames.bottom.location.reload ();
Method 3. window.parent.frames["Bottom"].location.reload ();
Method 4. Window.parent.frames.item (1). Location.reload ();
Method 5. Window.parent.frames.item (' Bottom '). Location.reload ();
Method 6. Window.parent.bottom.location.reload ();
Method 7. window.parent[' Bottom '].location.reload ();
Here is a framework to illustrate the use of these 7 methods, which includes three HTML pages:
Frame.html: The main frame, consisting of the top and bottom two child frames pages.
Top.html: On the frame.
Buttom.html: Next frame.
Assume that there is a refresh button in the top.html frame, and then click to refresh the contents of the frame bottom.html.
Main frame frame.html Code:
The code is as follows |
Copy Code |
<HTML> <HEAD> <TITLE> Main Frame </TITLE> </HEAD> <frameset rows= "50%,50%" > <frame name=top src= "top.html" > <frame Name=button src= "button.html" > </frameset> </HTML>
|
On the frame top.html code, there are some refresh buttons:
The code is as follows |
Copy Code |
<body> <input Type=button value= "Method 1 Refresh" onclick= " Window.parent.frames[1].location.reload () "><br> <input Type=button value=" Method 2 Refresh "onclick=" Window.parent.frames.bottom.location.reload () "><br> <input Type=button value=" Method 3 Refresh "onclick=" window.parent.frames[' Bottom '].location.reload () ><br> <input Type=button value= "Method 4 Refresh" onclick= " Window.parent.frames.item (1). Location.reload () "><br> <input Type=button value=" method 5 Refresh "onclick=" Window.parent.frames.item (' Bottom '). Location.reload () "> br> <input Type=button value=" Method 6 Refresh "onclick=" Window.parent.bottom.location.reload () "><br> <input Type=button value=" Method 7 Refresh "onclick=" window.parent[' Bottom '].location.reload () ><br> </body> |
The next Frame bottom.html code, which is a JS window, in the frame loading, on the frame of JS is activated to demonstrate the effect of the refresh.
The code is as follows |
Copy Code |
<HTML> <HEAD> </HEAD> <body onload= "alert (' I was loaded!") ') ' > </BODY> </HTML> |
The above 7 kinds of methods you can choose one, according to your actual situation selection, compare the entire frame to refresh the JS code.