如何自动调整iframe的大小? [英] How to auto size an iframe?

查看:103
本文介绍了如何自动调整iframe的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用iframe来显示内容,但内容的高度可能会有所不同,我想尝试对垂直滚动条进行缩放。我知道你可以在CSS或HTML中有一个可变高度或溢出。有没有办法可以使用JavaScript?

I''m trying to use an iframe to show content but the height of the content can vary and I want to try and elimate the vertical scroll bar. I know that you can have a variable height or an overflow in CSS or HTML. Is there a way I can do this using JavaScript?

推荐答案

你可以通过检查body offsetHeight来设置高度onload(在iframe中)。
You could set the height onload (within the iframe) by checking the body offsetHeight.


这不仅仅是获得浏览器窗口的大小。我需要知道框架需要多大才能适应它的所有内容。有没有办法解决这个问题?
Doesn''t that just get the size of the browser window. I need to know how big the frame needs to be to fit all it''s content. Is there a way to work that out?


我的意思是在iframe中,所以它会得到iframe的身高。
I meant within the iframe, so it''d get the iframe body height.


这篇关于如何自动调整iframe的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆