Javascript设置获取iframe页面元素与页面重载方法
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"); |
参考
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