Jay's 무한 Story ♬

팝업 사이즈 자동 조절 스크립트(팁) 본문

프로그래밍/JavaScript

팝업 사이즈 자동 조절 스크립트(팁)

Mr.Jay 2009. 11. 18. 20:39
자바가 어렵다^^
고로 스크립트도 어렵다~
그렇지만 인터넷에는 없는게 없다^^ 인터넷으로 공부하면 만사 오케바리?!! ㅋ >.<

첫번째 방법

<Script Language=JavaScript>
function winResize(){
  width  = parseInt(document.body.clientWidth -  document.images[0].width)+10;
  height = parseInt(document.body.clientHeight -  document.images[0].height)+10;
  window.resizeTo(width,height)
}
</Script>

====================================

<body onload="winResize()">

<!-- 요기에 팝업관련 쓰기-->

</body>


두번째 방법

<Script Language=JavaScript>
function PopupAutoResize() {
    window.resizeTo(100, 100);
    var thisX = parseInt(document.body.scrollWidth);
    var thisY = parseInt(document.body.scrollHeight);
    var maxThisX = screen.width - 50;
    var maxThisY = screen.height - 50;
    var marginY = 0;
    //alert(thisX + "===" + thisY);
    //alert("임시 브라우저 확인 : " + navigator.userAgent);
    // 브라우저별 높이 조절.
    if (navigator.userAgent.indexOf("MSIE 6") > 0) marginY = 60;        // IE 6.x
    else if(navigator.userAgent.indexOf("MSIE 7") > 0) marginY = 80;    // IE 7.x
    else if(navigator.userAgent.indexOf("Firefox") > 0) marginY = 50;   // FF
    else if(navigator.userAgent.indexOf("Opera") > 0) marginY = 30;     // Opera
    else if(navigator.userAgent.indexOf("Netscape") > 0) marginY = -2;  // Netscape
    if (thisX > maxThisX) {
        window.document.body.scroll = "yes";
        thisX = maxThisX;
    }
    if (thisY > maxThisY - marginY) {
        window.document.body.scroll = "yes";
        thisX += 19;
        thisY = maxThisY - marginY;
    }
    window.resizeTo(thisX+10, thisY+marginY);
}
</Script>
============================================

<body onLoad="PopupAutoResize();">

<!-- 요기에 팝업관련 쓰기-->

</body>

Comments