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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.