As a behavior

Rewriting scripts to behaviors are almost always easy. I've used the attachEvent to hook up the onmousemove and onmouseup events. these were added to the document. The onmousedown was caught at the element (not on the document level). Doing this allowed me to remove the test for valid elements. I also added an initiation phase were I checked the position style and if it wasn't set I set to relative.

Setting up behaviors are always easy. All you need to do is add behavior: url(""); to your style declarations


This is the handle

This is a div that's moved with a handle. The title has the class="handle" and the custom attribute handlefor that has the value of the id that it should move

It has the position style set to relative

This is a div that you can grab anywhere
This div has the class="moveme"

It has the position style set to absolute and the top and left set to 600 and 300 respectively

This on is like the other div but I've set the custom attribute called dontraise to true

Drag and Drop
Setting up the page
As a behavior

Author: Erik Arvidsson