본문 바로가기

디자인

[자바스크립트]레이어 팝업2

<!---------------------------------스크립트팝업시작--------------------------------->
<SCRIPT type=text/javascript>
<!--
 function getCookie(name) {
  var Found = false;
  var start, end;
  var i = 0;

  while(i <= document.cookie.length) {
   start = i;
   end = start + name.length;

   if(document.cookie.substring(start, end) == name) {
    Found = true;
    break;
   }
   i++;
  }

  if(Found == true) {
   start = end + 1;
   end = document.cookie.indexOf(";", start);
   if(end < start)
    end = document.cookie.length;
   return document.cookie.substring(start, end);
  }
 }


isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;

function ddInit(e){
topDog=isIE ? "BODY" : "HTML";
whichDog=isIE ? document.all.divpop : document.getElementById("divpop");
hotDog=isIE ? event.srcElement : e.target;
while (hotDog.id!="divpop"&&hotDog.tagName!=topDog){
 hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
}
if (hotDog.id=="divpop"){
 offsetx=isIE ? event.clientX : e.clientX;
 offsety=isIE ? event.clientY : e.clientY;
 nowX=parseInt(whichDog.style.left);
 nowY=parseInt(whichDog.style.top);
 ddEnabled=true;
 document.onmousemove=dd;
}
}

function dd(e){
if (!ddEnabled) return;
whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx;
whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
return false;
}

document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false");

 

 //메인팝업관련 쿠키설정
 function setCookie( name, value, expiredays )
 {
  var now = new Date();
  now.setDate( now.getDate() + expiredays );
  document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + now.toGMTString() + ";"
 }

 //메인팝업감추기
 function closeDiv()
 {
  var divpop = document.getElementById( "divpop");
  var checkbox = document.getElementById( "checkbox");

  if( checkbox.checked==true) {
  setCookie( "viewPop", "ok" , 1 );
  }
  divpop.style.visibility = "hidden";
 }
// -->
   </SCRIPT>

<DIV id=divpop style="Z-INDEX: 150; LEFT: 200px; POSITION: absolute; TOP: 100px; border:solid; border-color:#dedede; border-width:2px" >
<FORM name=divpopfrm>
 <TABLE cellSpacing=0 cellPadding=0 border=0 style="border:solid; border-color:#f0f0ee; border-width:4px" >
  <TR>
   <TD style="PADDING: 6px 6px 5px 6px" align=right background="popup/images/drag_bg_top.gif"><TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
     <TR>
      <TD align=left><strong>브니엘 산부인과</strong></TD>
      <TD width=16><IMG style="CURSOR: pointer" onclick=closeDiv(); src="popup/images/btn_close.gif" border=0></TD>
     </TR>
    </TABLE></TD>
  </TR>
  <TR>
   <TD style="padding:0 5px 0 5px" background="popup/images/drag_bg_mid.gif"><IMG src="popup/pop_event.jpg" border=0></TD>
  </TR>
  <TR>
   <TD style="PADDING: 5px 6px 6px 6px" align=right background="popup/images/drag_bg_bottom.gif"><TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
     <TR>
      <TD style="PADDING-RIGHT: 10px" align=right><INPUT onfocus='this.blur();' id=checkbox type=checkbox value=checkbox name=checkbox>
       <LABEL for=checkbox>오늘은 더이상 보지않기</LABEL></TD>
      <TD width=21><IMG style="CURSOR: pointer" onclick=closeDiv(); src="popup/images/btn_close_2.gif" border=0></TD>
     </TR>
    </TABLE></TD>
  </TR>
 </TABLE>
 </DIV>
</FORM>
<SCRIPT type=text/javascript>
<!--
 var divpop = document.getElementById( "divpop");
 cookiedata = document.cookie;
 if(cookiedata.indexOf("viewPop=ok") < 0){
  divpop.style.visibility = "visible";//사용을 원하면 hidden ->visible 로 바꿔주세요.
 }
 else{
  divpop.style.visibility = "hidden";
 }
//-->
   </SCRIPT>
<!---------------------------------스크립트팝업끝--------------------------------->