팝업창 띄우기 옵션 및 방법

미랑 · 2006-05-02 18:54:41
[ 팝업창 옵션 ]

=> yes / no 또는 0 / 1 을 사용

width=800 : 팝업창의 넓이
height=600 : 팝업창의 높이
top=0 : 팝업창이 뜰 위치
left=0 : 팝업창이 뜰 위치
resizable=1 : 창크기 조정가능
scrollbars=1 : 스크롤바
menubar=1 : 메뉴
toolbar=1 : 메뉴아이콘
location=1 : 제목표시줄
directories=1 : 연결버튼(핫메일 등)
status=1 : 하단의 상태바


1. 입장시 팝업창 띄우기

<head>
<title>입장시 자동으로 팝업창 띄우기</title>
<!-- 삽입해야 할 소스 시작 -->
<script language="javascript">
<!--
function OpenWindow() {  
      window.open("insa-hi.html","_blank","top=0,left=0,width=470,height=340,resizable=1,scrollbars=no");
}
//-->
</script>
</head>
<body onLoad="OpenWindow()">
<!-- 삽입해야 할 소스 끝 -->

또는

<!-- 삽입해야 할 소스 시작 -->
<body onload="window.open('insa-hi.html', 'new', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no, resizable=no,width=470,height=340')">
<!-- 삽입해야 할 소스 끝 -->



2. 퇴장시 팝업창 띄우기

<!-- 삽입해야 할 소스 시작 -->
<body onunload="popup();">
<script language=javascript>
<!--
function popup()
{
  window.open("testby.html", "_blank",
      "top=0,left=0,width=463,height=178" +
      ",toolbar=1,status=1,scrollbars=0,resizable=0");
}
-->
</script>
<!-- 삽입해야 할 소스 끝 -->

또는

<!-- 삽입해야 할 소스 시작 -->
<body onunload="window.open('testby.html')">
<!-- 삽입해야 할 소스 끝 -->



3. 클릭을 하면 팝업창이 뜨는 스크립트

<title>링크 클릭시 팝업창 띄우기</title>

<!-- 삽입해야 할 소스 시작 -->
<script language="javascript">
<!--
function OpenWindow(url,intWidth,intHeight) {
      window.open(url, "_blank", "width="+intWidth+",height="+intHeight+",resizable=1,scrollbars=1") ;
}
//-->
</script>
</head>

<body>
<br>
<center>
<a href="javascript:OpenWindow('insa-hi.html','470','340')">여기를 누르면 새로운 창을 띄웁니다.</a>
</center>
<!-- 삽입해야 할 소스 끝 -->

</body>



4. 입장시와 퇴장시에 모두 팝업창 띄우기

<!-- 삽입해야 할 소스 시작 -->
<!--입장 팝업 소스 -->
<body onunload="popup();">
<SCRIPT LANGUAGE="JavaScript">
<!--
function popup( partner )
{
  window.open("insa-hi.html", "_blank", "top=0,left=0,width=450,height=340",
              "toolbar=1,status=1,scrollbars=1,resizable=1");
}  
popup(  );
-->
</SCRIPT>

<!--퇴장 팝업 소스 -->
<script language=javascript>
<!--
function popup()
{
  window.open("insa-by.html", "_blank", "top=0,left=0,width=470,height=350",
              "toolbar=1,status=1,scrollbars=0,resizable=0");
}
-->
</script>
<!-- 삽입해야 할 소스 끝 -->