달력

05

« 2012/05 »

  •  
  •  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  •  
  •  
2009/03/11 16:02

iframe 사이즈 자동조절 tip/javascript2009/03/11 16:02

1.아래 코드를 아이프레임이 들어갈 메인페이지에 삽입세요.

function resizeFrame(iframeObj){
  var innerBody = iframeObj.contentWindow.document.body;
  var innerHeight = innerBody.scrollHeight + (innerBody.offsetHeight - innerBody.clientHeight);
  var innerWidth = innerBody.scrollWidth + (innerBody.offsetWidth - innerBody.clientWidth);
 
    if(innerHeight>0 && innerWidth>0){
        iframeObj.style.height = innerHeight;
        iframeObj.style.width = innerWidth;
    }
}

2. 아래와 같이 iframe을 호출하는 부분에서 onload 이벤트에서 호출하면 끝!.

<iframe src="" name="iPub_list" onload="resizeFrame(this)" style="width:100%" frameborder="0" scrolling="no"></iframe>

'tip > javascript' 카테고리의 다른 글

div태그로 지정된 영역만 출력  (0) 2009/05/06
iframe 사이즈 자동조절  (0) 2009/03/11
HTML 간단한 새창 띄우기  (0) 2009/03/03
Posted by 根™