Resize iframe to content with Jquery

前端 未结 6 2179
孤街浪徒
孤街浪徒 2020-12-03 18:08

I\'m trying to resize an iframe dynamicly to fit its content. To do so I have a piece of code:

$(\"#IframeId\").height($(\"#IframeId\").contents().find(\"htm         


        
6条回答
  •  眼角桃花
    2020-12-03 18:43

    What you can do is the following:

    • Within the iFrame use document.parent.setHeight(myheight) to set the height within the iFrame to the parent. Which is allowed since it is a child control. Call a function from the parent.

    • Within the parent you make a function setHeight(iframeheight) which resizes the iFrame.

    Also see:
    How do I implement Cross Domain URL Access from an Iframe using Javascript?

提交回复
热议问题