这个需求一般用于移动端
html
<iframe id="ididid" src="https://hao.360.cn"></iframe>
JS部分
<script type="text/javascript">
function autoHeight(){
if (window.innerHeight){//FF
nowHeight = window.innerHeight;
}else{
nowHeight = document.documentElement.clientHeight;
}
var jianHeight = 0; //随padding值改变
if(nowHeight > jianHeight){
document.getElementById('ididid').style.height = nowHeight - jianHeight + 'px';
}else{
document.getElementById('ididid').style.height = jianHeight + 'px';
}
}
autoHeight();
window.onresize = autoHeight;
</script>
























18605917465
客服QQ