div设置了高度自适应,但是在div里面插入一个iframe,用js使iframe获取到div的高度,但是对iframe不起作用
你们说的都不行吖,我说的是div是自适应高度的,让div的高度iframe的高度变化,我已经给iframe设置了宽度是100%,框架的高度是多少,让div随着iframe的高度变化。div中的iframe是一个搜索操作,搜索出来的结果有时候会很多。
//window.onresize表示窗口触发时间的时候执行
//两个函数,用闭包包裹起来()()
window.onload=function(){
(window.onresize=function(){
//获取可见宽度
var width=document.documentElement.clientWidth-180;//180为左边的div的大小
//获取可见高度
var height=document.documentElement.clientHeight-80;//80为头部的div的大小可自己修改
//如果有宽度就给值,
if(width>=0){
document.getElementById('main').style.width=width+'px';
}
if(height>=0){
document.getElementById('sidebar').style.height=height+'px';
document.getElementById('main').style.height=height+'px';
}
})()};
//设置iframe的高度
function resizeFrameHeight() {
$('.tab_iframe').css('height', document.documentElement.clientHeight - 118);
$('md-tab-content').css('left', '0');
}
window.onresize = function () {
resizeFrameHeight();
initScrollShow();
initScrollState();
}