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 >

 

 

 

你可能感兴趣的:(iframe)