묻고답하기
[질문]팝업창 자동으로 한번만 뜨게 하기
2009.06.16 11:51
홈페이지를 바꾸려고 하는데요
팝업창 소스를 구해서 적용을하는데 팝업이 걸려있는 게시판 클릭시 계속 뜹니다.
하루에 한번만 뜨게 자동으로 차단하는 방법이 없을까요
인터넷으로 쿠키를 적용하는 방법이 있다는데
아래 소스에 어떻게 적용을 해야하는지요
// head사이에 넣을 부분
<script>
var dragapproved=false
var minrestore=0
var initialwidth,initialheight
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all
function iecompattest(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
function drag_drop(e){
if (ie5&&dragapproved&&event.button==1){
document.getElementById("dwindow").style.left=tempx+event.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+event.clientY-offsety+"px"
}
else if (ns6&&dragapproved){
document.getElementById("dwindow").style.left=tempx+e.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+e.clientY-offsety+"px"
}
}
function initializedrag(e){
offsetx=ie5? event.clientX : e.clientX
offsety=ie5? event.clientY : e.clientY
document.getElementById("dwindowcontent").style.display="none" //extra
tempx=parseInt(document.getElementById("dwindow").style.left)
tempy=parseInt(document.getElementById("dwindow").style.top)
dragapproved=true
document.getElementById("dwindow").onmousemove=drag_drop
}
function loadwindow(url,width,height){
if (!ie5&&!ns6)
window.open(url,"","width=width,height=height,scrollbars=1")
else{
document.getElementById("dwindow").style.display=''
document.getElementById("dwindow").style.width=initialwidth=width+"px"
document.getElementById("dwindow").style.height=initialheight=height+"px"
document.getElementById("dwindow").style.left="550px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset*1+30+"px" : iecompattest().scrollTop*1+30+"px"
document.getElementById("cframe").src=url
}
}
function maximize(){
if (minrestore==0){
minrestore=1 //maximize window
document.getElementById("maxname").setAttribute("src","http://jamtingi80.cafe24.com/images/restore.gif")
document.getElementById("dwindow").style.width=ns6? window.innerWidth-20+"px" : iecompattest().clientWidth+"px"
document.getElementById("dwindow").style.height=ns6? window.innerHeight-20+"px" : iecompattest().clientHeight+"px"
}
else{
minrestore=0 //restore window
document.getElementById("maxname").setAttribute("src","http://jamtingi80.cafe24.com/images/max.gif")
document.getElementById("dwindow").style.width=initialwidth
document.getElementById("dwindow").style.height=initialheight
}
document.getElementById("dwindow").style.left=ns6? window.pageXOffset+"px" : iecompattest().scrollLeft+"px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset+"px" : iecompattest().scrollTop+"px"
}
function closeit(){
document.getElementById("dwindow").style.display="none"
}
function stopdrag(){
dragapproved=false;
document.getElementById("dwindow").onmousemove=null;
document.getElementById("dwindowcontent").style.display="" //extra
}
</script>
// body 사이에 넣기 -팝업창 불러오기
<div id="dwindow" style="background-color:rgb(239,239,239); border-width:1px; border-color:rgb(34,34,34); border-style:solid; width:200px; height:200px; position:absolute; left:0px; top:0px; z-index:1; cursor:hand; layer-background-color:rgb(239,239,239); " onMousedown="initializedrag(event)" onMouseup="stopdrag()" onSelectStart="return false">
<table width=100% cellpadding=3 cellspacing=0 border=0>
<td bgcolor=c0c0c0 style=font-family:tahoma;font-size:8pt;> <B>:: 뚱이와뚱땡이의 최근소식</B></td>
<td bgcolor=c0c0c0 align=right><img src="http://jamtingi80.cafe24.com/images/max.gif" id="maxname" onClick="maximize()"><img src="http://jamtingi80.cafe24.com/images/close.gif" onClick="closeit()"></td>
</tr>
</table>
<div id="dwindowcontent" style="height:100%;"><iframe id="cframe" src="" width=100% height=100%></iframe></div>
</div>
<script>
if (ns6) window.onload=new Function('loadwindow("http://jamtingi80.cafe24.com/popup.htm",420,470)')
else
loadwindow("http://jamtingi80.cafe24.com/popup.htm/",420,470)
</script>
<a href="javascript:loadwindow('http://jamtingi80.cafe24.com/popup.htm/',420,470)"></a>