同学录的设计
源代码在线查看: drag.js
var dragapproved=false
var eventsource,x,y
//eventsource=document.winstepsform
function move()
{
if (event.button==1&&dragapproved) //改变被拖动元素在页面上的位置
{
eventsource.style.pixelLeft=temp1+event.clientX-x
eventsource.style.pixelTop=temp2+event.clientY-y
return false
}
}
function drags()
{
if (!document.all)
return
if (event.srcElement.className=="drag") //捕捉鼠标和被拖动元素的当前位置
{
dragapproved=true
eventsource=event.srcElement
//alert(eventsource.style.name)
temp1=eventsource.style.pixelLeft
temp2=eventsource.style.pixelTop
x=event.clientX
y=event.clientY
document.onmousemove=move
}
}
document.onmousedown=drags //鼠标左键按下时,准备拖动
document.onmouseup=new Function("dragapproved=false")//鼠标左键放开时,拖动停止