Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

drag <div> object with mouse

Status
Not open for further replies.

cgreynes

Programmer
Feb 28, 2003
29
US
hi! i have a calendar layer on my page. how do i drag the layer using the mouse? the code below is slow. i have to drag the layer slowly or else the layer will be left behind.

<div id='calendar' onmousedown='setMouseXY(event);bMoveCalendar=true;' ondragstart='doDragStart();' onmousemove='doMouseMove(event);' onmouseup='bMoveCalendar=false;'>
<!--calendar code-->
<div>

function setMouseXY(e)
{
if (!bMoveCalendar)
{
mouseX=e.clientX;
mouseY=e.clientY;
}
}

function doDragStart()
{
event.returnValue=false;
}

function doMouseMove(e)
{
var i;
if (bMoveCalendar)
{
i=e.clientX-mouseX;
if (i!=0)
{
calendarX+=i;
crossobj.left=calendarX;
mouseX=e.clientX;
}

i=e.clientY-mouseY;
if (i!=0)
{
calendarY+=i;
crossobj.top=calendarY;
mouseY=e.clientY;
}
event.returnValue=false;
event.cancelBubble=true;
}
}

thanks so much in advance
clark
 
thanks gary! the code works in IE and Netscape v7. i have been working with this for days.

right now my only problem is that my calendar layer is displaying behind the combo boxes. i've read thru the forums and they say that it is one of the problems in IE. just made a temporary solution by making the combo box hidden when the layer is behind it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top