<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script language="javascript" type="text/javascript">
var isCatchDiv = false;
var dragX = 0;
var dragY = 0;
function loadDiv(divMove){
var divMove=document.getElementById(divMove);
divMove.style.top=document.body.scrollTop+300;
divMove.style.left=document.body.scrollLeft+250;
}
function hideDiv(divMove){
var divMove=document.getElementById(divMove);
divMove.style.visibility = "hidden";
}
function showDiv(){
loadDiv("");
var divMove=document.getElementById(divMove);
divMove.style.visibility = "visible";
}
function catchDiv(divMove){
isCatchDiv = true;
var divMove=document.getElementById(divMove);
var x=event.x+document.body.scrollLeft;
var y=event.y+document.body.scrollTop;
dragX=x-divMove.style.pixelLeft;
dragY=y-divMove.style.pixelTop;
divMove.setCapture();
document.onmousemove = moveDiv
}
function releaseDiv(divMove){
isCatchDiv = false;
var divMove=document.getElementById(divMove);
divMove.releaseCapture();
document.onmousemove = null;
}
function moveDiv(divMove){
if(isCatchDiv){
var divMove=document.getElementById(divMove);
divMove.style.left = event.x+document.body.scrollLeft-dragX;
divMove.style.top = event.y+document.body.scrollTop-dragY;
}
}
window.onload =showDiv; (无法获取DIV的ID,写在什么地方呢?)
}
</script>
<div style="width: 160px; height: 30px;cursor:move; position:absolute ;" id="div1" onmousedown="catchDiv(this.id)" onmouseup="releaseDiv(this.id)">
<asp:Label ID="Label1" runat="server" Font-Size="XX-Large" Text="####" Width="198px"></asp:Label></div>