<div id="fancybox-content" style="height:200px;">
<iframe id="fancybox-frame">
<html>
<head></head>
<body>
<div class="inner-div"><p class="click-here">Button</p></div>
</body>
</html>
</iframe>
</div>
div#fancybox-content 的初始高度为 200px,但在单击按钮时,div.inner-div 的高度会增加。 所以我也想增加 div#fancybox-content 的高度。
那么如何使用Jquery实现呢?
最佳答案
IFrame 是否与您的外部页面在同一个域中?如果不是,您必须使用消息发布来执行此操作。
例如在外窗:
myIframe.contentWindow.postMessage('hello', '*');
在 iframe 中:
window.onmessage = function(e){
if (e.data == 'hello') {
alert('It works!');
}
}
关于jquery - 如何使用Jquery从iframe标签的内部元素访问iframe标签的外部元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22805424/