if(self==top){//}判断窗口是否处于顶级
if(self==parent){}//也可以
<iframe name="test" src="child.html"></iframe>
window.frames["test"].document.getElementById('menu');
//由于所有的函数都存放在window对象里面,可去掉开头的window:
frames["test"].document.getElementById('menu');
//在浏览器中,帧的name属性被默认等同于子页面的window对象,因此可以进一步简写:
test.document.getElementById('menu');
//假如child.html定义了showMesg函数,需要在父中调用,则这样写 window.frames['test'].showMesg(); //简写形式 test.showMesg(); //同理,对象也是如此访问 alert(test.person);
<iframe id="testId" src="child.html"></iframe>
//======
var doc=document.getElementById('testId');
//或者
var doc=document.getElementsByTagName('iframe')[0];
然后
var winOrdoc=doc.contentDocument||doc.contentWindow;//二选一
if(winOrdoc.document)winOrdoc=winOrdoc.document;
winOrdoc.getElementById('menu');
//如果需要window对象,则这样写:
if(winOrdoc.defaultView)winOrdoc=winOrdoc.defaultView;
parent.window.document.getElementById('parentMenu');
//简写
parent.document.getElementById('parentMenu');
parent.parentFunction();
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有