iframe获取父页面window(父页面获取iframe中的内容)

本文目录
父页面获取iframe中的内容
父页面读写操作子页面:
《iframe id="test-iframe" name="test-iframe" src="child.html" scrolling="no" frameborder="0"》《/iframe》
《script》
window.onload = function () {
/*
* 下面两种获取节点内容的方式都可以。
* 由于 IE6, IE7 不支持 contentDocument 属性,所以此处用了通用的
* window.frames
*/
var d = window.frames.document;
d.getElementsByTagName(’h1’).innerHTML = ’pp’;
alert(d.getElementsByTagName(’h1’).firstChild.data);
}
《/script》
注:在请务必通过 window.onload 方法访问 iframe 中的节点,否则浏览器会提示错误-拒绝访问。在 IE8, Firefox3.6, Opera11 下在 DOMReady 时也可以访问 iframe 中的节点。
iframe中页面跳转之后如何获取父窗口
输出脚本
- C# code
- string js = "《script》window.parent.location.href=’页面URL’;《/script》";
ClientScript.RegisterClientScriptBlock(this.GetType(), "myJS", js);
或者
- JScript code
- window.parent.location.href=’’;
Javascript刷新页面的几种方法:
1 history.go(0)
2 window.location.reload()
window.location.reload(true)
3 location=location
4 location.assign(location)
5 document.execCommand(’’Refresh’’)
6 window.navigate(location)
7 location.replace(location)
8 document.URL=location.href
Frame框架:
frame.html:
《frameset rows="50%,50%"》
《frame name=top src="top.html"》
《frame name=bottom src="bottom.html"》
《/frameset》
七种语句:
语句1. window.parent.frames.location.reload();
语句2. window.parent.frames.bottom.location.reload();
语句3. window.parent.frames.location.reload();
语句4. window.parent.frames.item(1).location.reload();
语句5. window.parent.frames.item(’’bottom’’).location.reload();
语句6. window.parent.bottom.location.reload();
语句7. window.parent.location.reload();
top.html 页面的代码如下:
《input type=button value="刷新1" onclick="window.parent.frames.location.reload()"》
bottom.html页面:
《body onload="alert(’’我被加载了!’’)"》
《h1》This is the content in bottom.html.《/h1》
《/body》
1.window指代的是当前页面,例如对于此例它指的是top.html页面。
2.parent指的是当前页面的父页面,也就是包含它的框架页面。例如对于此例它指的是frame.html。
3.frames是window对象,是一个数组。代表着该框架内所有子页面。
4.item是方法。返回数组里面的元素。
5.如果子页面也是个框架页面,里面还是其它的子页面,那么上面的有些方法可能不行。
如果想关闭窗口时刷新或者想开窗时刷新的话,在《body》中调用以下语句即可。
《body onload="opener.location.reload()"》 开窗时刷新
《body onUnload="opener.location.reload()"》 关闭时刷新
//子窗口刷新父窗口
《script language=JavaScript》
self.opener.location.reload();
《/script》
( 或 《a href="javascript:opener.location.reload()"》刷新《/a》 )
子iframe 怎么访问 父的 iframe方法
jquery、js调用iframe父窗口与子窗口元素的方法
1. jquery在iframe子页面获取父页面元素代码如下:
$("#objid",parent.document)
2. jquery在父页面获取iframe子页面的元素
代码如下:
$("#objid",document.frames(’iframename’).document)
3.js在iframe子页面获取父页面元素代码如下:
indow.parent.document.getElementByIdx_x("元素id");
4.js在父页面获取iframe子页面元素代码如下:
window.frames.document.getElementByIdx_x("元素id");
5.子类iframe内调用父类函数:
window.parent.func();

更多文章:
118论坛手机打不开了怎么回事?118图118论坛网址怎么变成卖茶叶的
2025年6月9日 10:45
西安abap开发培训(SAP ABAP培训,ABAP培训怎么样)
2025年12月31日 01:00
loopback下载(如何在ubuntu命令行下下载kvm)
2026年4月9日 08:30
security video(bios setup utility怎么设置开机密码 不是登陆密码啊)
2026年1月30日 08:00
asp session用法(关于ASP.NET中session的用法)
2026年5月16日 08:30
斯莱德男装品牌倒闭了(jj,马华,esprit,斯莱德,zara,美邦,这几个品牌如何评价)
2026年7月10日 12:30
covered interest rate parity(Interest Rate Parity代表什么)
2026年2月19日 06:00
特斯拉model3百公里加速(model3百公里加速是多少)
2026年1月18日 10:00
php执行mysql语句(php连接mysql数据库,执行查询语句后,排序后再输出)
2025年11月5日 18:30












