Scripting in Drag



Can anyone help me solve this? I am trying to modify the below script
which allows elements of class="drag" to be dragged around the screen
by a user. I need to get (either as a hidden text box or a variable to
be used in other functions (including vbscript
functions) the coordinates of a dragged object after the drag
operation ie to know exactly where each draggable element is at all
times.

Any help massively appreciated. Dan.

<style type="text/css">
.drag{
position:relative;
cursor:hand;
z-index: 100;
}
</style>
<script type="text/javascript">
/***********************************************
* Drag and Drop Script: © Dynamic Drive (http://
www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s
more.
***********************************************/
var dragobject={
z: 0, x: 0, y: 0, offsetx : null, offsety : null, targetobj :
null, dragapproved : 0,
initialize:function(){
document.onmousedown=this.drag
document.onmouseup=function(){this.dragapproved=0}
},
drag:function(e){
var evtobj=window.event? window.event : e
this.targetobj=window.event? event.srcElement : e.target
if (this.targetobj.className=="drag"){
this.dragapproved=1
if (isNaN(parseInt(this.targetobj.style.left)))
{this.targetobj.style.left=0}
if (isNaN(parseInt(this.targetobj.style.top)))
{this.targetobj.style.top=0}
this.offsetx=parseInt(this.targetobj.style.left)
this.offsety=parseInt(this.targetobj.style.top)
this.x=evtobj.clientX
this.y=evtobj.clientY

if (evtobj.preventDefault)
evtobj.preventDefault()
document.onmousemove=dragobject.moveit
}
},
moveit:function(e){
var evtobj=window.event? window.event : e
if (this.dragapproved==1){
this.targetobj.style.left=this.offsetx+evtobj.clientX-this.x
+"px"
this.targetobj.style.top=this.offsety+evtobj.clientY-this.y
+"px"
return false
}
}
}

dragobject.initialize()
</script>

.



Relevant Pages

  • Scripting problem in drag!-)
    ... Can any of you Jscipters help me? ... functions) the coordinates of a dragged object after the drag ... Drag and Drop Script: © ... var evtobj=window.event? ...
    (microsoft.public.scripting.jscript)
  • Re: PYTHONPATH var
    ... value for this var. ... PYTHONPATH is an environment variable. ... I don't have to modify any Python source code. ... first item of this list, path, is the directory containing the script ...
    (comp.lang.python)
  • Cacading script question
    ... like to modify this script to do two things: ... CASCADE MENU SCRIPT ... {var Elements = PElement.children ... HTML CODE from FrontPage ...
    (microsoft.public.scripting.jscript)
  • How to access variables in an iframe?(Opera,JavaScript)
    ... in Firefox and IE, but fails in Opera. ... Can I modify the code to meet ... var l=document.getElementById; ...
    (alt.html)
  • Re: How to access variables in an iframe?(Opera,JavaScript)
    ... Can I modify the code to meet ... opera's standard? ... var l=document.getElementById; ...
    (alt.html)