클릭하면 해당페이지로 이동하는 공지사항 팝업창 만들기
블로그를 옮겼으니 기존의 블로그 구독자들에게 공지는 해야겠는데, 효과적으로 알릴 수 있는 방법이 없을까 싶어 팝업창을 선택했습니다. 아래의 소스를 변형해서 이용하시면 됩니다.
<head>와 </head>사이에 넣어야 할 웹코드
<script language="JavaScript1.2">
var ns4=document.layers;
var ie4=document.all;
var ns6=document.getElementById&&!document.all;
var dragswitch=0;
var nsx;
var nsy;
var nstemp;
function DragDropNS(name){
if (!ns4)
return;
temp=eval(name);
temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP);
temp.onmousedown=GoNS;
temp.onmousemove=DragNS;
temp.onmouseup=StopNS;
}
function GoNS(e){
temp.captureEvents(Event.MOUSEMOVE);
nsx=e.x;
nsy=e.y;
}
function DragNS(e){
if (dragswitch==1){
temp.moveBy(e.x-nsx,e.y-nsy)
return false
}
}
function StopNS(){
temp.releaseEvents(Event.MOUSEMOVE)
}
function DragDropIE(e){
if (ie4&&dragapproved){
oCross.style.left=tempx+event.clientX-offsetx
oCross.style.top=tempy+event.clientY-offsety
return false
}
else if (ns6&&dragapproved){
oCross.style.left=tempx+e.clientX-offsetx
oCross.style.top=tempy+e.clientY-offsety
return false
}
}
function InitDrag(e){
oCross=ns6? document.getElementById("showpopup") : document.all.showpopup;
var oBar=ns6? e.target : event.srcElement
var topelement=ns6? "HTML" : "BODY";
while (oBar.tagName!=topelement&&oBar.id!="dragbar"){
oBar=ns6? oBar.parentNode : oBar.parentElement;
}
if (oBar.id=="dragbar"){
offsetx=ie4? event.clientX : e.clientX;
offsety=ie4? event.clientY : e.clientY;
tempx=parseInt(oCross.style.left)
tempy=parseInt(oCross.style.top)
dragapproved=true
document.onmousemove=DragDropIE;
}
}
document.onmousedown=InitDrag;
document.onmouseup=new Function("dragapproved=false");
function Drag_onMouseOver(){
dragswitch=1;
if (ns4) DragDropNS(showpopup)
}
function Drag_onMouseOut(){
dragswitch=0;
}
function Drag_doHideBox(){
if (ie4||ns6)
oCross.style.visibility="hidden";
else if (ns4)
document.showpopup.visibility="hide";
return false;
}
</script>
<body>와 </body>사이에 넣어야 할 웹코드
<div id="showpopup" style="position:absolute;right:400px;top:100px; z-index:100">
<table border="0" width="20" bgcolor="#A1A1A1" cellspacing="0" cellpadding="1">
<tr>
<td width="100%">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td id="dragbar" style="cursor:hand" width="100%">
<ilayer width="100%" onSelectStart="return false">
<layer width="100%" onMouseOver="Drag_onMouseOver()" onMouseOut="Drag_onMouseOut()">
<!-- 메세지를 입력 하세요 ---->
<img src="이미지속성주소" onClick="location.href='링크할주소';return Drag_doHideBox();">
<!-- 여기까지 메세지 입력----->
</layer>
</ilayer>
</td>
</tr>
<tr>
<td align=right bgcolor=#3366CC>
[<a href="#" onClick="return Drag_doHideBox();"><font color="#FFFFFF"><b><small>종료</small></b></font></a>]
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>