Jump to content

drag and drop tutorial - looking for explaination


lilman

Recommended Posts

I found this tutorial online, and although the code works perfectly, they didn't explain hardly anything.  The most puzzling thing out of this code is that it doesn't use semicolons. Below is the code, if someone wouldn't mind, please explain why it is able to run without them.

 

<head>
<style>
<!--
.drag{position:relative;cursor:hand}
-->
</style>
<script language="JavaScript1.2">
<!--
/*Credit JavaScript Kit www.javascriptkit.com*/
var dragapproved=false
var z,x,y
function move()
{
    if (event.button==1&&dragapproved){

    z.style.pixelLeft=temp1+event.clientX-x

    z.style.pixelTop=temp2+event.clientY-y

    return false

    }
}

function drags()
{

    if (!document.all)

    
    return

    

    if (event.srcElement.className=="drag"){

    
    dragapproved=true

    
    z=event.srcElement

    
    temp1=z.style.pixelLeft

    
    temp2=z.style.pixelTop

    
    x=event.clientX

    
    y=event.clientY

    
    document.onmousemove=move

    }
}

document.onmousedown=drags
document.onmouseup=new Function("dragapproved=false")
//-->
</script>

</head>
<body>

<img src="http://www.google.com/intl/en_ALL/images/logo.gif" class="drag"><br>
<img src="http://www.adobe.com/shockwave/download/images/flash_rune.gif" class="drag"><br>
<b>"Hi there</b>
</body>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.