1,实现javascript重载iframe页面,兼容各浏览器的方法
代码如下 | 复制代码 |
document.getElementById(FrameID).contentWindow.location.reload(true); |
2,其次是获取iframe内的元素并应用
代码如下 | 复制代码 |
iframe.contentWindow.document.getElementById(id).style.display="block"; |
3,iframe页面调用父级页面中的函数
parent.dofunction();
contentWindow 实例
代码如下 | 复制代码 |
iframe = document.getElementById("frame"); iframe.contentWindow.location = "http://mozilla.org"; iframe.contentWindow.history.back(); |
参考
http://www-archive.mozilla.org/docs/dom/domref/dom_frame_ref5.html
The contentWindow property returns the window object for the frame.
Syntax
代码如下 | 复制代码 |
frameWindow = frameElement.contentWindow |
Parameters
frameWindow is an object reference to the window object for this frame.
Example
代码如下 | 复制代码 |
f = document.getElementById("frame"); f.contentWindow.location = "http://mozilla.org"; f.contentWindow.history.back(); |
Notes
You can also get to the window object through a named frame. For example, a frame with the name="myFrame" can refer back to the window object as window.frames["myFrame"].
Specification
DOM Level 2 -- HTMLFrameElement
时间: 2024-07-29 13:33:02