Crossbrowser Drag Handler | JavaScriptSource

Crossbrowser Drag Handler

JavaScriptSource Staff Jun 18, 2007


Ever wanted to drag an element or image around on your Web page? Just attach this drag handler to any number of elements on the page and you will be able to drag them all. Note that the elements must be positioned either relatively or absolutely.

Start drag process...

Drag me!

Drag me too!


Be sure that the elements are positioned either relatively or absolutely.

Source Code

Paste this source code into the designated areas.

External file

Paste this code into an external JavaScript file named: dragHandler.js


Paste this code into the HEAD section of your HTML document.


Paste this code into the BODY section of your HTML document

Leave a Response


In order to properly answer your question, you will need to post it over on [a href=""]the JavaScript forum[/a]. Thanks!

Lee Jan 16, 2009

I really like this script. However, I am having trouble implementing it. I have copied and pasted the code as instructed as well as created the js file. Is there any reason why this would not work due to settings?

V Nov 24, 2008

What exactly do you mean when you say:[br /][br /]"Be sure that the elements are positioned either relatively or absolutely."[br /][br /]What other way is there to position an element?[br /][br /]Are you saying that all elements must be positioned in the same way, i.e., either all relatively, or all absolutely?

Bob Jul 23, 2007

Excellent script - I used it on the logo for my site and added a "drag me!" message.[br /][br /]VERY NICE!

Nick Jun 18, 2007