根据嵌入页面的高度,设置iframe的高度

window.onload=function(){
// var winHeight=window.screen.height-100;
// $("#iframe").height(winHeight);
var iframe = document.getElementById("iframe");
try{
var bHeight = iframe.contentWindow.document.body.scrollHeight;
var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
var height = Math.max(bHeight, dHeight);
iframe.height = height;
}catch (ex){}

}

 

 

 

 

 

<script type="text/javascript">
window.onload=function(){
//    var winHeight=window.screen.height-100;
//    $("#iframe").height(winHeight);
    var iframe = document.getElementById("iframe");
    try{
    var bHeight = iframe.contentWindow.document.body.scrollHeight;
    var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
    var height = Math.max(bHeight, dHeight);
    iframe.height =  height;
    }catch (ex){}
    
}

</script>
</head>
<body style="margin:0px;"  onunload="closePapge()">
    <iframe id="iframe" height="100%" width="100%" frameborder="0" marginheight="0" marginwidth="0" name="index" id="index" src="<s:property value="examInfo.serviceUrl"/>&drgoUrl=<%=basePath %>jsp/course/domain.jsp" ></iframe>
<!--    <div id="paper" height="550" width="1000" ></div>-->
<input type="hidden" id="examId"></input>
</body>
</html>

 

posted on 2015-04-01 14:33  tarrying  阅读(1014)  评论(0)    收藏  举报