Javascript Reference
Categories: ondrag

javascript ondrag Description

@July 13, 2008, 6:08 a.m.
ondrag, ondragend, ondragstart Firefox/Netscape/NN n/a IE 5(Win) Chrome/Safari/DOM n/a  
  Bubbles: Yes; Cancelable: Yes  

When the user starts dragging a selection, the browser fires one ondragestart event on the selection's parent element, followed by a series of ondrag events, and then one ondragend event when the user releases the mouse button. All three event types fire on the same element during the drag.

 

During the drag operation, the user sees the cursor in one of its various forms, rather than seeing the actual element float around the page. As long as the user keeps the mouse button down following an initial drag action, the ondrag event keeps firing. Other drag-related events fire on other elements along the way (events such as ondragenter for an element that finds the dragged cursor in its airspace), but the ondrag event also fires at various instances.

 

An element with content that is dragged receives events in the following sequence: ondragstart, ondrag (perhaps many times), and ondragend. Elements in the path of the drag action receive ondragenter, ondragover, and ondragleave events, while the element at the end of the drag receives the ondrop event (which fires before the ondragend event of the dragged element). The speed of the drag action and client system speed impacts the number of event firings of all drag types. A fast drag on a slow machine may result in some events not firing.

 
Typical Targets

All rendered elements and document object.


Powered by Linode.