Auto-resize iframe based on content height

2019-08-06 11:45发布

I have a site on my server that is pulling in an iframe from an external site in which I do not have access.

I want the iframe to resize the height based on the content that is being pulled in so the page as a whole looks like a single page.

*I do not need to know how to get rid of the scroll bars.

Does anyone have any ideas? Thanks in advance!

3条回答
forever°为你锁心
2楼-- · 2019-08-06 12:04

What do you mean by 'the height of the content'? Is it an image, block of text, a table? You might be able to get round it using some kind of AJAX, but it will depend on the type of content in the iframe.

查看更多
smile是对你的礼貌
3楼-- · 2019-08-06 12:05

in css try

#frame_ID{
  height:auto;
}

I tried a whole bunch of things in css to see if there was any way to tell when the iframe didn't have a scrollbar and I found no solution so. Like the comment says this will not work.

查看更多
来,给爷笑一个
4楼-- · 2019-08-06 12:14

I don't think it's possible. There is no way to interact with an iframe with JavaScript. That would have serious security consequences so browsers don't allow it.

查看更多
登录 后发表回答