<div class="content-body">
<iframe class="frame" src="<?php echo base_url()?>assets/file/help/install_php.html" marginwidth="0" marginheight="0" frameborder="0" scrolling="no"></iframe>
</div>
根据iframe中内容设置iframe显示的高度
//设置iframe的高度
autoResize();
function autoResize() {
var iframeHeight = $(".frame").contents().find("body").height();
$(".frame").css("height",iframeHeight+20);
}
或者
function autoResize() {
var iFrames = $('.frame');
function iResize() {
for (var i = 0, j = iFrames.length; i < j; i++) {
iFrames[i].style.height = iFrames[i].contentWindow.document.body.offsetHeight + 'px';
}
}
if ($.browser.safari || $.browser.opera) {
iFrames.load(function(){
setTimeout(iResize, 0);
});
for (var i = 0, j = iFrames.length; i < j; i++) {
var iSource = iFrames[i].src;
iFrames[i].src = '';
iFrames[i].src = iSource;
}
} else {
iFrames.load(function() {
this.style.height = this.contentWindow.document.body.offsetHeight + 'px';
});
}
}