Search results for 'corss browser'

cross browser iframe auto resize

firefox 3.5 에서 iframe resize 스크립트가 작동하지 않는 문제로 골머릴 썩다 발견한 해결책.

원문 : http://overfloweb.com/zbxe/?mid=study&category=363&document_srl=741

test browser : ie6, ie7, firefox 3, safari 3, chrome, opera 9
...
<iframe id="contentFrame" name="contentFrame" src="about:blank" marginwidth="0" marginheight="0" frameborder="0" width="100%" height="100%" scrolling="no"></iframe>
...

...
<div id="content">
... contents ...
</div>
...
<script type="text/javascript">
function init(){
  var doc = document.getElementById('content');
  if(doc.offsetHeight == 0){
  } else {
  pageheight = doc.offsetHeight;
  parent.document.getElementById("contentFrame").height = pageheight+"px";
  }
}
window.onload = function(){
  init();
}
</script>
...



iframe 안의 소스에서 내용이 들어가는 전체를 <div id="content"></div> 로 감싸고,

onload 이벤트로 그 div 의 dom.offsetHeight 를 구해서 parent.iframe 의 height 를 바꿔주는 방식이다.
붉은색으로 표시된 height 가 크로스 브라우징의 핵심이다.
겨우 height 가 핵심이냐고? 모르는 소리다.

clientHeight, scrollheight,innerHeight, 등등 모두 크로스브라우징은 안된다. 하지만 그냥 height 는 된다.

이 글의 관련글
  • Javascript Array 의 유용한 메소드들
  • Java Blueprints web application layout 과 Jakarta web application layout의 차이
  • 자주 사용되는 ie6 관련 CSS Hack
  • 웹호스팅 서비스 결재주기 변경
  • Servlet 3.0 스펙에 기인한 보안 논쟁 (1)
  • NetBeans 6.1의 놀라운 javascript 에디팅 기능
  • JavaScript Base64 Encode / Decode
  • 위치를 알아차리는(location-aware) 웹브라우징
  • 2009 웹트렌드 맵
  • 2009/11/16 12:23 2009/11/16 12:23
    Trackback Address:http://www.yunsobi.com/blog/trackback/511
    [로그인][오픈아이디란?]