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");
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

Javascript设置获取iframe页面元素与页面重载方法的相关文章

jQuery判断iframe中元素是否存在的方法

  jQuery判断iframe中元素是否存在的方法比较简单只要判断框架window.frames["iframepage"]指定值是不是存在就可以了,下面整理了一些例子大家可进入参考. 例子  代码如下   if($(window.frames["iframepage"].document).find('.l-grid-row-cell').length > 0){ alert(1); }else{ alert(2); } 以上代码,判断id为iframep

解析Jquery取得iframe中元素的几种方法

iframe在复合文档中经常用到,利用jquery操作iframe可以大幅提高效率,这里收集一些基本操作,需要的朋友可以参考下   DOM方法:父窗口操作IFRAME:window.frames["iframeSon"].document IFRAME操作父窗口: window.parent.documentjquery方法:在父窗口中操作 选中IFRAME中的所有输入框: $(window.frames["iframeSon"].document).find(&q

解析Jquery取得iframe中元素的几种方法_jquery

DOM方法:父窗口操作IFRAME:window.frames["iframeSon"].documentIFRAME操作父窗口: window.parent.documentjquery方法:在父窗口中操作 选中IFRAME中的所有输入框: $(window.frames["iframeSon"].document).find(":text");在IFRAME中操作 选中父窗口中的所有输入框:$(window.parent.document).

JS实现设置ff与ie元素绝对位置的方法_javascript技巧

本文实例讲述了JS实现设置ff与ie元素绝对位置的方法.分享给大家供大家参考,具体如下: function Show_menu(liid,divid) { var li=document.getElementById(liid); var div=document.getElementById(divid); div.style.left=getLeft(li)+140+'px'; div.style.top= getTop(li)+'px'; var tt=div.style.top; div

javascript实时获取鼠标坐标值并显示的方法

  这篇文章主要介绍了javascript实时获取鼠标坐标值并显示的方法,涉及javascript操作鼠标事件的相关技巧,非常具有实用价值,需要的朋友可以参考下 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Trans

javascript实时获取鼠标坐标值并显示的方法_javascript技巧

本文实例讲述了javascript实时获取鼠标坐标值并显示的方法.分享给大家供大家参考.具体实现方法如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml&quo

js获取iframe中对应的页面属性

问题描述 描述:a.jsp包含了b.jsp,而b.jsp是一个树形结构的控件,b.jsp以iframe的方式包含在了a.jsp中,a.jsp包含b.jsp的方式如下:<td height=100% width=18% valign="top"><iframe name="treeselected" src="page/jqueryTree/userAreaCheckBoxTree1.jsp" frameBorder="

JavaScript设置获取和设置属性的方法_javascript技巧

getAttribute 该方法用来获取元素的属性,调用方式如下所示: 复制代码 代码如下: object.getAttribute(attribute) 以此前介绍的一些方法不同,getAttribute方法不属于document对象,所以不能通过document对象调用.它只能通过元素节点对象来调用. 该方法只接受一个参数,你指定要查询的属性的名字.如果指定的属性没有设置,结果将返回null对象. setAttribute 以上面作用相反的是setAttribute,该方法被用来设置元素节点

常见页面元素遮住菜单解决方法

菜单|解决|页面 1.被Flash挡住 设置Flash的参数:<param name="wmode" value="opaque"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#versio