如何根据iframe中的动态conent来改变iframe的高度? [英] How to change height of iframe based on dynamic conent within the iframe?
问题描述
这是一个我试图使用jsFiddle放在一起的例子:
iframe: http://jsfiddle.net/B4AKc/2/
页面: http://jsfiddle.net/PmBrd/
任何想法?
代码:
var iframe = document.getElementById(ifr)。contentWindow;
iframe $(。toggle_div)。bind(change,function(){
$(#ifr)css({
height:iframe $(body)。outerHeight()
});
});
既然你提到他们在同一个域中,这只是一个类似于你真实的事情app。
I have an iframe that has dynamic content. If the answers specific questions, additional information displays (hidden div becomes visible). I'd like the height of the iframe to expand. I know this question has been asked on here multiple times, but it seems like it is typically when a different page within the iframe is loaded, not when content is changed dynamically within the iframe.
Here is an example I tried to put together using jsFiddle:
iframe: http://jsfiddle.net/B4AKc/2/
page: http://jsfiddle.net/PmBrd/
Any ideas?
Does this work for you?
Code:
var iframe = document.getElementById("ifr").contentWindow;
iframe.$(".toggle_div").bind("change", function () {
$("#ifr").css({
height: iframe.$("body").outerHeight()
});
});
Since you mentioned they are in the same domain, it's just a matter of doing something similar with your real app.
这篇关于如何根据iframe中的动态conent来改变iframe的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!