简体   繁体   English

iframe调整大小解决方案-跨浏览器兼容的解决方案

[英]IFrame Resize Solution - A Cross-Browser Compatible Solution

New Year Greetings Y'all.... 新年祝福...

I know there are some references to this issue here on stackoverflow, but I found none of them quite useful. 我知道在stackoverflow上有一些对此问题的引用,但是我发现它们都不十分有用。 I've an Iframe whose src attribute is dynamically set through PHP. 我有一个Iframe,其src属性是通过PHP动态设置的。 I would like it to resize itself according to it's content ( JavaScript) . 我希望它根据其内容(JavaScript)调整自身大小。 Any insights? 有什么见解吗?

(Solutions mentioned on this site for the same problem faced do not work for me) (此站点上提到的解决相同问题的解决方案对我不起作用)

Thank You, Abhijit 谢谢阿比吉特

Best solution: Don't use an IFrame, but embed the content inside a div. 最佳解决方案:不要使用IFrame,而是将内容嵌入div中。 That will give you much more control. 这将给您更多的控制权。 An IFrame is more or less a black box. IFrame或多或少是一个黑匣子。 I don't think the document outside the box can not what is in the box (for security reasons), so it cannot perform calculations either. 我不认为框外的文档不能包含框内的内容(出于安全原因),因此它也无法执行计算。 The document inside the box doesn't even know that it's inside an IFrame. 框内的文档甚至都不知道它位于IFrame中。

The best option would be to let the PHP document determine which page is shown, but do that a little earlier, so you can use that fact to render a slight difference in the parent document as well. 最好的选择是让PHP文档确定显示哪个页面,但是要早一点做,因此您也可以使用该事实在父文档中稍有不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM