function fnDown(event) {
event=event||window.event;
var loginPanel=document.getElementById('loginPanel');
disX =event.clientX-loginPanel.offsetLeft;
disY = event.clientY-loginPanel.offsetTop;
document.onmousemove=function(event){
event=event||window.event;
var changedisX=event.clientX-disX,
changedisY=event.clientY-disY,
winW=document.documentElement.clientWidth||document.body.clientWidth,
winH=document.documentElement.clientHeight||document.body.clientHeight,
maxW=winW-loginPanel.offsetWidth,// loginPanel 不可以从fnDown()取得值吗?
maxH=winH-loginPanel.offsetHeight;
if (changedisX<0) {
changedisX=0;
}else if (changedisX>maxW) {
changedisX=maxW;
}
loginPanel.style.left=changedisX+"px";
loginPanel.style.top=changedisY+"px";
}
document.onmouseup=function(){
document.onmousemove=null;
document.onmoseup=null;
}
// body...
}
添加回答
举报
0/150
提交
取消