龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > Javascript编程 >

Javascript设置获取iframe页面元素与页面重载方法

时间:2012-12-29 08:41来源:未知 作者:admin 点击:
分享到:
文章详细的介绍了Javascript设置获取iframe页面元素与页面重载方法,这些主要是兼容ie,ff等主流浏览器,有需要的朋友可以参考一下。 1,实现javascript重载iframe页面,兼容各浏览器的方法
文章详细的介绍了Javascript设置获取iframe页面元素与页面重载方法,这些主要是兼容ie,ff等主流浏览器,有需要的朋友可以参考一下。

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


精彩图集

赞助商链接