HTML and CSS Reference
Figure 7-14. A drag-and-drop operation in progress (top) and completed (bottom)
In addition to the draggable attribute, there is the global dropzone attribute.
This attribute can in theory be used to specify what kind of data a particular drop target
expects to receive as well as what kind of drag-and-drop operation is going on (the spe-
cification lists move , link , and copy as its possible values), which in theory could
be used to replace any logic introduced in the dragenter and dragleave events.
However, at the time of writing, you'll have to wait for this feature to be implemented
across the major web browsers.
The syntax for handling events in this topic has looked like the following, for ex-
window.onload = init;
This is an older syntax that I've used because of its wide support, but you should
be aware of a newer, more flexible syntax for handling events that you are likely to
run into. The addEventListener() method can be added to associate an event
handler function with an event. The preceding line of code could be rewritten as fol-
window.addEventListener( "load" , init , false );
This associates the load event with the function init() , so in this syntax the “on”
prefix is left off the event. The advantages of this syntax are as follows: