iframe自适应屏幕高度

<iframe id="ididid" src="https://hao.360.cn">
</iframe>

<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>

posted @ 2016-02-18 14:42  爱努力的小疯子  阅读(1243)  评论(0编辑  收藏  举报