2007年9月3日 星期一

使用div標籤顯示特別訊息




以下是程式碼:

==================================

<script language="JavaScript1.2">

/*
DHTML Announcement Box- By Jim Silver @ jimsilver47@yahoo.com
Exlusive permission granted to Dynamic Drive (http://dynamicdrive.com) to include this script in their DHTML archive.
For full source code, terms of use, and 100's more scripts, visit http://dynamicdrive.com
*/

//drag drop function for NS 4////
/////////////////////////////////

var dragswitch=0
var nsx
var nsy
var nstemp

function drag_dropns(name){
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)
}

//drag drop function for IE 4+////
/////////////////////////////////

var dragapproved=false

function drag_dropie(){
if (dragapproved==true){
document.all.showimage.style.pixelLeft=tempx+event.clientX-iex
document.all.showimage.style.pixelTop=tempy+event.clientY-iey
return false
}
}

function initializedragie(){
iex=event.clientX
iey=event.clientY
tempx=showimage.style.pixelLeft
tempy=showimage.style.pixelTop
dragapproved=true
document.onmousemove=drag_dropie
}

if (document.all){
document.onmouseup=new Function("dragapproved=false")
}

////drag drop functions end here//////

function hidebox(){
if (document.all)
showimage.style.visibility="hidden"
else if (document.layers)
document.showimage.visibility="hide"
}

</script>

<div id="showimage" style="position:absolute; left:197px; top:226px; overflow: visible; var o = true">
<table border="0" bgcolor="#FF0000" cellspacing="0" cellpadding="1">
<tr>
<td width="100%" ><table border="0" width="100%" cellspacing="0" cellpadding="5">
<tr>
<td onmousedown="initializedragie()" width="96%" bgcolor="#FF0000"><strong><font color="#FFFFFF">聲明啟事!!</font></strong></td>
<td width="1%" align="center" bgcolor="#FF0000"><a href="#" onclick="hidebox();return false" style="text-decoration:none"><font color="#FFFFFF">X</font></a></td>
</tr>
<tr>
<td colspan="2" align="center" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="350" height="250">本中心由衷感謝舊雨們多年來的支持與愛護!</td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2" align="center"><a href="#" onclick="hidebox();return false" style="text-decoration:none"><font color="#FFFFFF">關閉視窗</font></a></td>
</tr>
</table>
</td>
</tr>
</table>
</div>