How to get iframe contentWindow height in cross domain

北战南征 提交于 2019-12-04 12:19:46

问题


i want to auto adjust my iframe height according to their content but in same domain it's work properly with contentWindow.height but in case of cross domain its permission denied for accessing iframe dom.


回答1:


For modern browsers you can use the window.postMessage function to communicate between the iFrames belonging to two different domains.

There are also several jQuery plugins that wrap window.postMessage with older URL hashing techniques for browsers that don't support window.postMessage. It makes the usage of the technology transparent to the end user.

You can look at the following page (and probably borrow the javascript you need) from here:

Lutron - Ballast Selection Tool

The tool with the dropdowns is actually being loaded from a separate domain into an iFrame. The iFrame is then dynamically resized based on the height of the inner content.



来源:https://stackoverflow.com/questions/3667627/how-to-get-iframe-contentwindow-height-in-cross-domain

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