팝업 창 크기를 HTML 크기에 맞추어 자동으로 크기를 조정하는 함수로 팝업 스크립트에 해당 메서드를 넣으면 된다.
예시 코드는 jQuery로 작성되어 있지만 JavaScript로 변경해서 사용해도 된다.
$(window).load(function() {
var strWidth;
var strHeight;
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 );
});
[JavaScript] 이미지 URL 혹은 파일 -> Base64 변경 후 다운로드 (0) | 2022.05.31 |
---|---|
[JavaScript] 윈도우 팝업 정 가운데 위치 시키기 (0) | 2022.05.31 |
[JavaScript] File Tag에 File List 할당해주기. (0) | 2020.10.05 |
[JavaScript/jQuery/Namespace] 이벤트 1회 적용하고 제거하기 (0) | 2020.09.16 |
[JavaScript/jQuery] JavaScript로 Caps Lock 체크 (0) | 2020.08.26 |
댓글 영역