$(document).ready(function(){
// 실행식
});
보다
이렇게 쓰는 것이 시간차를 줄일 수 있다
제이쿼리가 들어왔는지 체크하는 식!!
function autoResizeIframe() {
$('iframe').on('load', function() {
if(this.contentDocument) {
$(this).height(this.contentDocument.documentElement.scrollHeight);
}
else {
$(this).height(this.contentWindow.document.body.scrollHeight);
}
});
}
.contentWindow
: iframe 최상위로 접근하는 메서드
.contentDocument
: .contentWindow의 바로 하위 메서드
.documentElement
: document 안에 있는 head와 body 모두를 포함하여 선택하는 메서드