HTML and CSS Reference
In-Depth Information
Drag-and-drop in all browsers
Although the HTML5 drag-and-drop API is based on what IE5.5 imple-
mented, it's not identical. What that means is that although it's possible
to write cross-browser code for drag-and-drop that works across
Firefox, Chrome/Safari, and IE, doing so isn't as straightforward as the
code given in the previous section.
PROBLEM 1
The draggable attribute is an innovation of the HTML5 spec, and IE8
doesn't recognize it. By default, nothing in the previous example is
draggable in IE .
SOLUTION 1
Links are draggable by default, so by making everything that should be
draggable a link, IE can be supported.
The initial code was simpleā€”a
draggable attribute and an event
handler:
Instead of making the list items
draggable, add links around the
text content:
<li draggable="true"
id="recpt"
ondragstart=
"dragstart(event)">
Reception
</li>
<li id="recpt">
<a ondragstart=
"dragstart(event);"
href="#"
onclick="return false;">
Reception
</a>
</li>
The draggable attribute is no lon-
ger required because links are
draggable by default.
 
Search WWH ::




Custom Search