팁이라기보단 참고정도로 봐주세요...^^;
prototypejs 를 이용하구요...일반적으로 사용하지 않는 분들도 테스트 해볼 수 있는 페이지를 따로 올려볼께욤 조만간에;;;
iframe resize 에 대해 질문도 많이 올라오고 해서 테스트 해보시라고 올립니다.

참고는 여기서...
http://ajaxstudy.net/demo/view.php?&uid=17&page=1

Event.observe(window,'load',function() {

    Event.observe('aa','load',function() {

        new ASiframeresize($('aa'));

    });

    new ASiframeresize($('aa'));

});

function ASiframeresize(el) {

    this.El = el;
    this.oldLocation = null;
    this.setCount = 0;
    this.maxCount = 10;
    this.setDelay = 200;
    this.setTimer = null;
    this.setup();


}

ASiframeresize.prototype = {

    setup : function() {

        var oThis = this;
        Event.observe(this.El.contentWindow.document,'mousedown', function(event) {

            if(Event.element(event).tagName.toLowerCase() != 'body') {

                if(oThis.setTimer) {
                    oThis.setCount = 0;
                    window.clearTimeout(oThis.setTimer);
                    oThis.setTimer = null;
                }
                oThis.resize();

            }

        });

        this.resize();

    },

    resize : function() {

        this.setCount++;

        if(this.El.contentWindow.document.body) {

            this.El.setStyle({
                
                height : this.El.contentWindow.document.body.offsetHeight + 'px'

            });

        } else {

            this.El.setStyle({
                
                height : this.El.contentWindow.document.documentElement.offsetHeight + 'px'

            });


        }
        this.move();

    },

    move : function() {

        if(this.setCount > this.maxCount) {

            this.setCount = 0;
            if(this.setTimer) {
                window.clearTimeout(this.setTimer);
                this.setTimer = null;
            }

        } else {

            var oThis = this;
            var fn = function(){ oThis.resize();}
            this.setTimer = window.setTimeout(fn,oThis.setDelay);

        }

    }

    

}

허접하지만 혹시라도 그럼^^;

출처: http://www.phpschool.com/gnuboard4/bbs/board.php?bo_table=ajax&wr_id=893&page=1
2009/04/27 19:07 2009/04/27 19:07

Trackback Address :: https://youngsam.net/trackback/346