使鼠标可以拖动图片。
<img src="pic/2006-8-21000爱戴.jpg" class="drag" title="拖动图片" />
<img src="pic/jpg-btn-deco.jpg" class="drag" />
<div class="drag">AAAAAAAAAA</div>
<script language="JavaScript">
var dragapproved=false
var z,x,y
function move(){
if (event.button==1&&dragapproved){
z.style.pixelLeft=temp1+event.clientX-x
z.style.pixelTop=temp2+event.clientY-y
return false
}}
function drags(){
if (!document.all)
return
if (event.srcElement.className=="drag"){
dragapproved=true
z=event.srcElement
temp1=z.style.pixelLeft
temp2=z.style.pixelTop
x=event.clientX
y=event.clientY
document.onmousemove=move
}}
document.onmousedown=drags
document.onmouseup=new Function("dragapproved=false")
</script>
本文使用Blog_Backup未注册版本导出,请到soft.pt42.com注册。