Javascript IE中的iFrame调整大小问题
我制作了一个脚本,将iFrame的大小重新调整到其内容的高度。它就像一个符咒,但不是在IE中。IE给了我在CSS中为iframe设置的大小。你知道我该怎么解决这个问题吗Javascript IE中的iFrame调整大小问题,javascript,jquery,internet-explorer,Javascript,Jquery,Internet Explorer,我制作了一个脚本,将iFrame的大小重新调整到其内容的高度。它就像一个符咒,但不是在IE中。IE给了我在CSS中为iframe设置的大小。你知道我该怎么解决这个问题吗 function iFramler($iFrames, $){ if($iFrames.length){ var resizeiFrame = function($iFrame){ console.log($iFrame.contents().find("body").height()
function iFramler($iFrames, $){
if($iFrames.length){
var resizeiFrame = function($iFrame){
console.log($iFrame.contents().find("body").height())
//gives back the iFrame height in IE not the height of the content :(
$iFrame.height( $iFrame.contents().find("body").height() + 40 );
};
$iFrames.each(function(){
var $that = $(this);
$that.load(function(){
resizeiFrame($that);
});
});
}else{
return false;
}
}
$iFrame[0].contentWindow.document.body.scrollHeight
有效scrollHeight
应该是一个doElement属性,而不是属性。那么$iFrame.contents().find('body')[0]呢。scrollHeight
?它应该是一个DomeElement属性,而不是一个属性。我得到错误:“contents().find(…).0.scrollHeight”为null或不是中的对象IE@timdream你给我指明了正确的道路。它与$iFrame[0].contentWindow.document.body.scrollHeight一起工作
,如果你用它来发布答案,我就给你一个重点。