'iframe'에 해당되는 글 1건

  1. 2008.09.05 iframe 사이즈 자동으로 조절하기
2008. 9. 5. 23:48
<!--StartFragment-->
<script language="javascript">
    function Resize_Frame(name) {
         try {  
           var oBody  = document.frames(name).document.body;
           var oFrame  = document.all(name);
           tempWidth = oBody.offsetWidth-oBody.clientWidth;
           oFrame.style.width = oBody.scrollWidth + tempWidth;
           tempHeight = oBody.offsetHeight - oBody.clientHeight;
           oFrame.style.height = oBody.scrollHeight + tempHeight;
           if (oFrame.style.height == "0px" || oFrame.style.width == "0px") {
                oFrame.style.width = "570px";
                oFrame.style.height = "500px";
                window.status = 'iframe resizing fail.';
           } else {
                window.status = '';
           }
          }  catch(e) {
               window.status = 'Error: ' + e.number + '; ' + e.description;
               //window.status = 'No-IFrame';
          }
     }
 </script>

<iframe omload="Resize_Frame('idBoard')" width=570 height=300 valign=top frameborder=0 src="t_board_org_admin.jsp?listID=jungbo15" name="idBoard" id=idBoard></iframe>

위와 같이 하면 된다. 단, iframe에 들어갈 페이지가 현재 iframe을 포함하고 있는 페이지와 서로 다른 머신이나 웹서버에 존재하면...엑세스가 거부되 작동이 되질 않는다...

이럴때는 어쩔 수 없이 iframe에 들어갈 페이지에 아래와 같은 스크립트를 넣어야하지만, 문제가 많다.

일단 페이지를 수정할 수 있어야하고 그 페이지가 다른 사이트에서 하나의 페이지로 존재한다면 그 페이지를 호출하면 스스로 사이징이 되버리기 때문이다...

<script language="javascript">
     function resizeSelf() {
          self.resizeTo(document.body.scrollWidth , document.body.scrollHeight + 10);
     }
</script> 
<body leftmargin="0" topmargin="0" omLoad="resizeSelf();"> 

Posted by ToTb