iframe自适应高度

 

<html>
<head>
<script>
function SetCwinHeight(obj) {
var cwin = obj;
if (cwin && !window.opera) {
if (cwin.contentDocument && cwin.contentDocument.body.offsetHeight) {
cwin.height
= cwin.contentDocument.body.offsetHeight + 20;
}
else if (cwin.Document && cwin.Document.body.scrollHeight) {
cwin.height
= cwin.Document.body.scrollHeight + 20;
}
}
else
{
if(cwin.contentWindow.document && cwin.contentWindow.document.body.scrollHeight){
cwin.height
= cwin.contentWindow.document.body.scrollHeight;
}
}
}
</script>
</head>
<body>

</body>
</html>
<iframe id="frmDetail" name="cwin" src="1.txt" width="778" height="200" onload="Javascript:SetCwinHeight(this)"
frameborder
="0" scrolling="no"></iframe>

 

 

 

posted @ 2010-05-17 11:42  佳乐比海  阅读(241)  评论(0编辑  收藏  举报