您的位置:首页 > 其它

iframe 自动适应页面大小

2010-10-27 16:18 330 查看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title>无标题文档</title>

<script type="text/javascript">

// function SetWinHeight(obj){

//var win=obj;

//if (document.getElementById){

//if (win && !window.opera){

// alert(win.document.body.scrollHeight);

// if (win.contentDocument&&win.contentDocument.body.offsetHeight)

// win.height = win.contentDocument.body.offsetHeight;

// else if(win.Document && win.Document.body.scrollHeight)

// win.height = win.document.body.scrollHeight;

//

// }

// }

//

//}

//iframe高度自适应

 //  function reinitIframe(obj){

// var iframe = obj;

// try{

// var bHeight = iframe.document.body.scrollHeight+200;

// var height = Math.max(bHeight, dHeight);

// iframe.height = height;

// alert(iframe.height);

// }catch (ex){

//

// }

// if(iframe.height<2000)

// window.setTime("reinitIframe()", 200);

// }

//var iframe=document.getElementById("win");;

function reinitIframe(){

var iframe = document.getElementById("win");

try{

var bHeight = iframe.document.body.scrollHeight;

var client=iframe.document.body.clientHeight;

var dHeight = iframe.document.documentElement.scrollHeight;

var height = Math.max(bHeight, dHeight);

var btitle = iframe.document.title;

iframe.height = document.body.scrollHeight;

document.title=btitle;

}catch (ex){}

alert(bHeight);

alert(client);

}

//window.setInterval("reinitIframe()", 2);

</script>

</head>

<body onload="parent.document.all.win.style.height=document.body.scrollHeight">

<iframe align="center" height="600" id="win" width="100%" name="win" src="盾诚科技/dagl.html" onload="javascript:reinitIframe(this)" frameborder="0" scrolling="no">

</iframe>

</body>

</html>

相关技术帖子:http://blog.sina.com.cn/gzwncb
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: