Prindol

DESIGN, HTML5, CSS3, DOM, Jquery, JSON, Actionscript2/3, Linux, IIS

You are not logged in.

#1 2015-01-08 14:40:58

skydown
Administrator
Registered: 2011-07-25
Posts: 315

[JAVASCRIPT] 팝업 리사이즈 resizeTo()

- 본문 크기와 브라우저 상황에 맞게 리사이징

$(document).ready(function(){
    $(function() {// 팝업 높이 설정
        if($('#popupContainer').length > 0) {
            var _docHeight = ($(document).height() <= $(window).height()) ? $(window).height() : $(document).height();
            $('#popupContainer').css('height', _docHeight - (parseInt($('#popupContainer').css('borderTopWidth')) + parseInt($('#popupContainer').css('borderBottomWidth'))) + 'px');
            popupAutoResize();
        }
    });

    $(function() {// 팝업 창 닫기
        $('#popupContainer a.close').click(function() {
            window.close();
        });
    });
});

function popupAutoResize() {
    var w = $(document).width();
    var h = $(document).height();
    window.resizeTo(w, h);
    
    var mw = window.outerWidth - window.innerWidth;
    var mh = window.outerHeight - window.innerHeight;
    window.resizeBy(mw, mh);
    
    if (msieversion() < 9) {
        mw = $(document).outerWidth() - $(window).width();
        mh = $(document).outerHeight() - $(window).height();
        window.resizeBy(mw, mh);
    }
}
function msieversion() {
    var ua = window.navigator.userAgent
    var msie = ua.indexOf ( "MSIE " )
    if ( msie > 0 ) // If Internet Explorer, return version number
        return parseInt (ua.substring (msie+5, ua.indexOf (".", msie )))
    else // If another browser, return 0
        return 0
}
// Javascript End

Offline

#2 2015-01-15 13:01:00

skydown
Administrator
Registered: 2011-07-25
Posts: 315

Re: [JAVASCRIPT] 팝업 리사이즈 resizeTo()

- 팝업 자동 리사이징 (IE, FF, CHROME)
- $('body > div > div') 본문 크기를 가늠 할 수 있는 영역

- 범용 컨텐츠 내용에 맞게 리사이징 (창크기가 내용 보다 크면 잡히지 않음)

    var w = $(document).width();
    var h = $(document).height();

- 데이터 로드 완료 후 리사이징

(function($) {
    $(function () {
        $(window).load(function () {
            popupAutoResize();//팝업리사이징
        });//load
    });//$

    function popupAutoResize() {//팝업리사이징
        var w = $('body > div > div').innerWidth();
        var h = $('body > div > div').innerHeight();
        //window.resizeTo(w, h);

        var mw = window.outerWidth - window.innerWidth;
        var mh = window.outerHeight - window.innerHeight;
        //window.resizeBy(mw, mh);
        window.resizeTo(w + mw, h + mh);
        if (msieversion() < 9 && msieversion() != 0) {
            mw = $(document).outerWidth() - $(window).width();
            mh = $(document).outerHeight() - $(window).height();
            window.resizeBy(mw, mh);
        }
    }
    function msieversion() {//익스버전체크
        var ua = window.navigator.userAgent
        var msie = ua.indexOf ( "MSIE " )
        if ( msie > 0 ) // If Internet Explorer, return version number
            return parseInt (ua.substring (msie+5, ua.indexOf (".", msie )))
        else // If another browser, return 0
            return 0
    }

})(jQuery);

Offline

#3 2015-01-20 16:56:56

skydown
Administrator
Registered: 2011-07-25
Posts: 315

Re: [JAVASCRIPT] 팝업 리사이즈 resizeTo()

** 최종 스크립트**
- IE7,8 리사이징 수정 (두번 더 리사이징 시키면서 사이즈 맞춤)

(function($) {
    $(function () {
        $(document).ready(function () {
        });//ready

        $(window).load(function () {
            popupAutoResize();//팝업리사이징
        });//load
    });//$

    function popupAutoResize() {//팝업리사이징
        var w = document.getElementsByTagName('div')[1].clientWidth;
        var h = document.getElementsByTagName('div')[1].clientHeight;
        window.resizeTo(w, h);

        var mw = window.outerWidth - window.innerWidth;
        var mh = window.outerHeight - window.innerHeight;
        window.resizeBy(mw, mh);

        if (msieversion() < 9 && msieversion() != 0) {
            // get window fake outer size
            var fakeOuterWidth = document.documentElement.clientWidth;
            var fakeOuterHeight = document.documentElement.clientHeight;

            // resize to innerSize
            window.resizeTo(fakeOuterWidth, fakeOuterHeight);

            // get window fake inner size
            var fakeInnerWidth = document.documentElement.clientWidth;
            var fakeInnerHeight = document.documentElement.clientHeight;

            // get delta
            deltaWidth = fakeOuterWidth - fakeInnerWidth;
            deltaHeight = fakeOuterHeight - fakeInnerHeight;
            window.resizeTo(w + deltaWidth, h + deltaHeight);
        }
    }
    function msieversion() {//익스버전체크
        var ua = window.navigator.userAgent
        var msie = ua.indexOf ( "MSIE " )
        if ( msie > 0 ) // If Internet Explorer, return version number
            return parseInt (ua.substring (msie+5, ua.indexOf (".", msie )))
        else // If another browser, return 0
            return 0
    }
})(jQuery);

Offline

Board footer

Powered by FluxBB