return (iX >= iX1 && iX <= iX2 && iY >= iY1 && iY <= iY2);
<p>Try dragging the red square onto the blue square.</p>
<div id=”div1” onmousedown=”handleMouseDown(event)”></div>
Advantages and disadvantages
The major advantage of simulated drag and drop is that it works across DOM-compliant browsers, such
as Internet Explorer 5.0+, Mozilla 1.0+, Safari 1.0+, and Opera 7.0+. This strategy is known to work
across multiple platforms, as well, because it uses basic DOM functionality.
Of course, simulated drag and drop doesn’t give you the hooks into the operating system that system
drag and drop provides. You can’t affect text or links being dragged by the user, and the dragged ele-
ments can only be dragged within a given window or frame. However, for most use cases, simulated
drag and drop gets the job done.
library, freely available from
. This library provides a set of
objects that encapsulate much of the simulated drag-and-drop process. You need only include the file
zdragdroplib.js in your page to take advantage of the functionality.
Drag and Drop
16_579088 ch13.qxd 3/28/05 11:41 AM Page 405