How to get the height of an iframe with javascript from inside the iframe? What about pages with multiple iframes?

后端 未结 5 395
粉色の甜心
粉色の甜心 2020-12-31 01:38

Is there a way to detect the height and width of an iframe, by executing a script from inside the iframe? I need to dynamically position some elements in the iframe accordi

5条回答
  •  独厮守ぢ
    2020-12-31 02:04

    Be aware that code like this:

    var thisIframesHeight = window.parent.$("iframe.itsID").height();
    

    will only be safe if the source of the iframe and parent window are from the same domain. If not you will get permission denied problems and you will have to take another approach.

提交回复
热议问题