-
iframe크기 자동조절Front-End/javascript 2011. 1. 14. 15:43
//iframe크기 자동조절
function resizeIF(Id)
{
//alert("1"+Id);
var obj = document.getElementById(Id);
var Body;
var H, Min;// 최소 높이 설정 (너무 작아지는 것을 방지)
Min = 200;// DOM 객체 할당
try
{
if (!document.all && obj.contentWindow.document.location.href== 'about:blank') {
setTimeout("resizeIF('"+Id+"')", 10);
return;
}Body = obj.contentWindow.document.getElementsByTagName('body');
//alert("body== "+Body[0]);
Body = Body[0];if (this.Location != obj.contentWindow.document.location.href) {
H = Body.scrollHeight + 5;
obj.style.height = (H<Min?Min:H) + 'px';this.Location = obj.contentWindow.document.location.href;
//alert("location== "+this.Location);
}
}
catch(e)
{
//alert("2"+e);
setTimeout("resizeIF('"+Id+"')", 10);
return;
}setTimeout("resizeIF('"+Id+"')", 100);
}