动态改变iframe的属性

使用window对象的属性,window.frames.mainFrame得到的iframe只能对它的内部的页面的对象进行各种控制,如下:(mainTable为一个table对象)
window.frames.mainFrame.document.all.mainTable.clientHeight

如果想动态改变iframe的属性,比如它的height属性,就的用document.frames.mainFrame来获取iframe。如下:(想动态改变iframe的height属性为该iframe的src属性中指定页面中table的height,可以在该src属性指定页面中写如下代码)
window.parent.document.all.mainFrame.height=document.all.mainTable.clientHeight;

msdn中的原话这两句也应该注意:
security note Security Alert   To protect user privacy and safeguard your applications, Internet Explorer restricts some interactions between frames that host Web pages from different domains. For more information about using the Dynamic HTML (DHTML) object model with the frame and iframe objects, see About Cross-Frame Scripting and Security and Security Considerations: Dynamic HTML.

Note  Properties of the iframe must be accessed using the prefix, document.all, for example, document.all.iframeId.marginWidth.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值