[英]Iframe working but Height always increase
你好,經過幾個小時的搜索,我發現一個適用於我的iframe的腳本,它有一個小問題,它永遠不會停止它增加高度,沒有停止...這里的代碼我在我的頁面添加這個腳本我想要iframe
<script>
function alertsize(pixels){
pixels+=0;
document.getElementById('myiframe').style.height=pixels+"px";
}
</script>
<script type="text/javascript">
var myHeight = 0;
setInterval(function(){
if(myHeight != document.body.scrollHeight){
myHeight = document.body.scrollHeight;
parent.alertsize(myHeight);
}
},500);
</script>
這是iframe:
<iframe id="myiframe" src="http://www.altasoft.gr/hermes/index.html"
name="myiframe" width="100%" height="100%" scrolling="no"
frameborder="0"></iframe>
問題是標記中的height="100%"
。 將其更改為固定的像素值,腳本將開始工作。 所以將height="100%"
改為height="1"
或者其他什么,確切的值並不重要。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.