鼠標拖動showimage組件,全部代碼如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head><body>
<div id="showimage" onMouseDown="initializedragie();" style="position:absolute; left:119px; top:45px; width:149px; height:118px; z-index:1"><img src="file:///E|/Funove/Web/images/banner.gif" width="468" height="83"></div>
<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)          
}          
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")          
}          
function hidebox(){          
if (document.all)          
showimage.style.visibility="hidden"          
else if (document.layers)          
document.showimage.visibility="hide"          
}          
</script>          </body>
</html>