2007年10月11日 星期四

[轉載]虛擬視窗

虛擬視窗 第一部份

================================================
<-script language="JavaScript1.2">
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; width: 257; left: 83; top: 25">
<-table CLASS="alpht" border="1" width="300" bgcolor="#555555" cellspacing="0" cellpadding="2">
<-tr><-td width="300"><-table border="0" width="300" cellspacing="0" cellpadding="2" height="1">
<-tr><-td CLASS="alpht" onMousedown="initializedragie()" style="cursor: move" width="501" height="1"><-font size="2">
<-ilayer width="100%" onSelectStart="return false">
<-layer width="100%" onMouseover="dragswitch=1;drag_dropns(showimage)" onMouseout="dragswitch=0"><-/layer><-/ilayer>
<-font color="f5f5f5" face="新細明體">◎虛擬視窗標題<-/font><-/font><-/td><-td style="cursor: hand" height="1" width="54">
<-p align="right"><-a href="#" onClick="hidebox();return false"><-font size="2" color="#FFFFFF">關閉<-/font><-/a><-/p><-/td><-/tr>
<-tr><-td CLASS="alpht" bgcolor="#ffffff" colspan="2" height="1" width="557" valign="top"><-font size="2" color="#008000">想要在首頁上貼上公告或廣告,<-br>但版面又沒位置,這程式絕對符合你的需要!<-br>而且虛擬視窗還可以讓訪客自由移動或關閉!<-/font><-/td><-/tr>
<-/table><-/table><-/div>

================================================
【修改程式碼】
皆下來你可以使用Microsoft FrontPage...等其它網頁編輯軟體來修改虛擬視窗的版面。

找出第一行的<-div id="showimage" style="position: absolute; width: 257; left: 83; top: 25">程式碼,修改「width (視窗長度)」、「left (與網頁右邊距離)」、「top (與網頁上方距離)」

再將全部程式碼中的「width」數值改成與步驟2的「width」數值一致。

沒有留言: