[JavaScript] 이런 젠장맞을 웹코딩-iFrame Resizing.
2013. 11. 19. 19:35ㆍCoders
이것저것 다 찾아 보았는데, 이거만 먹더군요.
iFrame 로딩 컨텐츠에 따라 높이 조절하는 소스입니다.
출처 : http://www.jquery2dotnet.com/2012/05/iframe-height-auto-resize-in-aspnet-c.html
function getDocHeight(doc) { doc = doc || document; var body = doc.body, html = doc.documentElement; var height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight); return height; } function setIframeHeight() { var ifrm = document.getElementById("<%=ActionFrame.ClientID%>"); var doc = ifrm.contentDocument ? ifrm.contentDocument : ifrm.contentWindow.document; ifrm.style.visibility = 'hidden'; ifrm.style.height = "10px"; // reset to minimal height ... ifrm.style.height = getDocHeight(doc) + "px"; ifrm.style.visibility = 'visible'; }
'Coders' 카테고리의 다른 글
Syntaxhighlighting 버그 수정. (0) | 2013.11.19 |
---|---|
[C#] Label.GetPreferredSize 메서드 (0) | 2013.11.15 |
[MSSQL] 동적 쿼리로 정렬을 주는 방법. (0) | 2013.08.28 |