JavaScript

이미지 프린트(팝업)
  • 조회수 4,645
  • 작성일 2008-07-29
  •  

① popup_coupon.php

<script language="javascript">
// 팝업창 사이즈 자동조절
function autoResizePopup()
{
        window.resizeTo(0,0);

        var Dwidth = parseInt(document.body.scrollWidth);
        var Dheight = parseInt(document.body.scrollHeight);

        var divEl = document.createElement("div");
        divEl.style.position = "absolute";
        divEl.style.left = "0px";
        divEl.style.top = "0px";
        divEl.style.width = "100%";
        divEl.style.height = "100%";
        document.body.appendChild(divEl);

        window.resizeBy(Dwidth-divEl.offsetWidth, Dheight-divEl.offsetHeight);
        document.body.removeChild(divEl);
}

// 팝업창 중앙으로 위치
function popup_center()
{
    var x,y;
    if (self.innerHeight) { // IE 외 모든 브라우저
        x = (screen.availWidth - self.innerWidth) / 2;
        y = (screen.availHeight - self.innerHeight) / 2;
    }else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict 모드
        x = (screen.availWidth - document.documentElement.clientWidth) / 2;
        y = (screen.availHeight - document.documentElement.clientHeight) / 2;
    }else if (document.body) { // 다른 IE 브라우저( IE < 6)
        x = (screen.availWidth - document.body.clientWidth) / 2;
        y = (screen.availHeight - document.body.clientHeight) / 2;
    }
    window.moveTo(x,y);
}
</script>
<body onload="autoResizePopup();popup_center();window.print();" leftmargin="0" topmargin="0">
<img src="<?=$_GET[filepath]?>" style="cursor:pointer;" onclick="window.close();">
</body>


② JavaScript

<script language="javascript">
function open_popup_window(url, width, height, is_scrollbar) {
        is_scrollbar = (is_scrollbar) ? "yes" : "no" ; // 스크롤바 생성여부
        window.open(url,"_blank","toolbar=no,location=no,status=no,menubar=no,scrollbars="+is_scrollbar+",resizable=no,width="+width+",height="+height+",top=0,left=0");
}
</script>




<img src="../inc/images/btn_print.gif" onClick="open_popup_window('./popup_coupon.php?filepath=<?=urlencode("/store/images/store_map01.gif")?>', 0, 0, false);" style="cursor:pointer;">