问题
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