Auto-resize iframe based on content height

这一生的挚爱 提交于 2019-12-13 19:28:04

问题


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!


回答1:


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.




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/3314276/auto-resize-iframe-based-on-content-height

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!