使用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 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.
动态改变iframe的属性
最新推荐文章于 2024-07-14 17:41:27 发布