본문 바로가기

JavaScript & jQuery

JS_ window.open


JS_팝업창 띄우기

window.open("팝업창 페이지 주소", "팝업창 이름", "속성");

속성 Ex)
menubar = yes/no ( 메뉴바 표시여부)
toolbar = yes/no (툴바 표시여부)
status = yes/no (상태표시줄 표시여부)
location = yes/no (주소입력줄 표시여부)
scrollbars = yes/no (스크롤바 표시여부)
resizable = yes/no (window 크기조절 가능여부)
width = 숫자 (window 폭 설정)
height = 숫자 (window 높이 설정)
top = 숫자 (y좌표값 설정)
left = 숫자 (x좌표값 설정)
세로 스크롤바만 생성: <body style="overflow-X:hidden">
가로 스크롤바만 생성: <body style="overflow-Y:hideen">


Ex)

function display_pop(path, w, h, pname, t, l) {
    cookie_pop = document.cookie;
    if (cookie_pop.indexOf("p1=no") < 0) {
        objPopupNews = window.open(path, pname, "width=" + w + ",height=" + h + ",top=" + t + ",left=" + l + ",scrollbars=no");
        if (objPopupNews == null) {
            //alert("차단된 팝업창을 허용해 주세요.");
        } else {
            objPopupNews.focus();
        }
    }
}
function getCookie(name) {
    var nameOfCookie = name + "=";
    var x = 0;
    while (x <= document.cookie.length) {
        var y = (x + nameOfCookie.length);
        if (document.cookie.substring(x, y) == nameOfCookie) {
            if ((endOfCookie = document.cookie.indexOf(",", y)) === -1) {
                endOfCookie = document.cookie.length;
                return unescape(document.cookie.substring(y, endOfCookie));
            }
        }
        x = document.cookie.indexof("", x) + 1;
        if(x == 0) break;
    }
    return "";
}

▶ 팝업띄우는 display_pop 함수호출
display_pop("/popup2012_02.html", 600, 640, "p1");