HTML and CSS Reference
In-Depth Information
PROBLEM 3
The ondragover attribute doesn't work in IE8 and before.
SOLUTION 3
There are two possible approaches to solving this problem. The first
approach is to handle the dragenter event, which older versions of IE
recognize, instead of the dragover event, which they do not.
If you don't need to support old
versions of IE , you don't need to
worry about the first approach,
although it's simple to fix:
In older versions of IE the
dragenter event has to be can-
celled instead of the dragover :
<ul id="drophere"
ondrop="drop(event)"
ondragover="dragOver(event)"
ondragenter=
"dragOver(event)">
<ul id="drophere"
ondrop="drop(event)"
ondragover="dragOver(event)">
Also note that IE8 and earlier
need the dragOver event to
return false; .
The second (and better) approach is to attach the event handler in
script rather than declaratively in the HTML markup. The advantage
of this approach is that, while attaching the handler declaratively will
cause the event to fire, canceling that event won't make the element a
drop target in IE8 and earlier. But if you use the proprietary attach-
Event() method to attach to the dragOver event in script, canceling that
will make the element a drop target. Attaching the event this way is
straightforward; the code is shown here:
<!--[if lte IE 8]>
<script>
document.getElementById(
'drophere'
).attachEvent(
'ondragover', dragover
);
</script>
<![endif]-->
 
Search WWH ::




Custom Search