日期:2014-05-16  浏览次数:20451 次

JS控制DIV弹出层移动

<div class="title" style="cursor:move;color:#1E5494;" onmousedown="yidong('apDiv1')">系统提示!<span class="close" onclick="tips_pop()">×</span></div>

?

?

?

var yd=0;
var x=0;
var y=0;
function yidong(obj){
yd=obj;
x=document.all(yd).offsetLeft-event.x;
y=document.all(yd).offsetTop-event.y;

}
function document.onmousemove()
{
?//document.getElementById("idShow1").innerHTML =x+event.x;
?//document.getElementById("idShow2").innerHTML =y+event.y;

?//document.getElementById("idShow3").innerHTML =document.getElementById("apDiv1").offsetWidth;
?//document.getElementById("idShow4").innerHTML =document.getElementById("apDiv1").offsetHeight;
?if(yd!="0")
?{
??if(x+event.x<=document.documentElement.clientWidth-document.getElementById(yd).offsetWidth)
??{
???document.all(yd).style.pixelLeft=x+event.x;
??}
??if(y+event.y<=document.documentElement.clientHeight-document.getElementById(yd).offsetHeight)
??{
???document.all(yd).style.pixelTop=y+event.y;
??}
?}
}
function document.onmouseup(){
event.srcElement.releaseCapture();
yd=0;
}