0
我有以下方法呼吁的iframe负荷:奇怪jQuery的iframe的高度显示
function resizeIframe() {
$("#content").css("height", "");
$("#content").css("width", "");
var iFrameHeight = $('iFrame').contents().height();
var iFrameWidth = $('iFrame').contents().width();
$("#content").css("height", iFrameHeight);
$("#content").css("width", iFrameWidth);
}
当这个被称为有很多文字的下方空的空间,以便iframe的高度大约为1457px。但奇怪的是,当我加警惕这样的:
function resizeIframe() {
$("#content").css("height", "");
$("#content").css("width", "");
var iFrameHeight = $('iFrame').contents().height();
var iFrameWidth = $('iFrame').contents().width();
alert($("#content").height()); <-------------this alert
$("#content").css("height", iFrameHeight);
$("#content").css("width", iFrameWidth);
}
加入此警报它适合于1050px内容大小后。我完全困惑,为什么它会这样做,或者如何解决这个问题。任何帮助表示赞赏。
您可以在答案中包含两个演示(例如,使用http://jsfiddle.net/)。另外,请从问题标题中删除错字。它应该是'怪异的',而不是'Wierd'。更好的是,选择一个更具描述性的标题。 – 2012-02-23 14:57:13
你什么时候调用该方法? – 2012-02-23 15:37:08
@KevinB - 下面是它的调用方式:$(document).ready(function(){(“#iFrame”)。load(function(){resizeIframe();}); } – NoviceMe 2012-02-23 15:43:20