민서네집

팝업창 크기 자동조절 자바스크립트 본문

WEB (HTML, CSS)

팝업창 크기 자동조절 자바스크립트

브라이언7 2017. 11. 18. 15:34

인터넷 어딘가에서 가져온 자바스크립트.

적어도 크롬 브라우저에서는 잘 작동한다.


id 가 contents 인 태그의 크기만큼 팝업 창 크기를 자동으로 조절한다.


$(window).load(function() {

<%-- // 팝업 창 크기를 HTML 크기에 맞추어 자동으로 크기를 조정하는 함수. --%>

var strWidth;

var strHeight;


//innerWidth / innerHeight / outerWidth / outerHeight 지원 브라우저

if ( window.innerWidth && window.innerHeight && window.outerWidth && window.outerHeight ) {

strWidth = $('#contents').outerWidth() + (window.outerWidth - window.innerWidth);

strHeight = $('#contents').outerHeight() + (window.outerHeight - window.innerHeight);

}

else {

var strDocumentWidth = $(document).outerWidth();

var strDocumentHeight = $(document).outerHeight();


window.resizeTo ( strDocumentWidth, strDocumentHeight );


var strMenuWidth = strDocumentWidth - $(window).width();

var strMenuHeight = strDocumentHeight - $(window).height();


strWidth = $('#contents').outerWidth() + strMenuWidth;

strHeight = $('#contents').outerHeight() + strMenuHeight;

}

//resize

window.resizeTo( strWidth, strHeight );

});



Comments