A global event handler for the dragover event.


var dragoverHandler = targetElement.ondragover;

Return value

The dragover event handler for element targetElement.


This example demonstrates using the ondragover attribute handler to set an element's dragover event handler.

<!DOCTYPE html>
<html lang=en>
<title>Examples of using the ondrag Global Event Attribute</title>
<meta content="width=device-width">
  div {
    margin: 0em;
    padding: 2em;
  #source {
    color: blue;
    border: 1px solid black;
  #target {
    border: 1px solid black;
function drag_handler(ev) {

function dragstart_handler(ev) {

function drop_handler(ev) {
 console.log("Drop"); = "lightyellow";

 var data = ev.dataTransfer.getData("text");;

function dragover_handler(ev) {
<h1>Examples of <code>ondrag</code>, <code>ondrop</code>, <code>ondragstart</code>, <code>ondragover</code></h1>
   <p id="source" ondrag="drag_handler(event);" ondragstart="dragstart_handler(event);" draggable="true">
     Select this element, drag it to the Drop Zone and then release the selection to move the element.</p>
 <div id="target" ondrop="drop_handler(event);" ondragover="dragover_handler(event);">Drop Zone</div>


Specification Status Comment
HTML Living Standard
The definition of 'ondragover' in that specification.
Living Standard  
HTML 5.1
The definition of 'ondragover' in that specification.
Recommendation Initial definition

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 4 3.5 (1.9.1) 10 12 3.1
Feature Android Android Webview Chrome for Android Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile
Basic support No support No support No support No support No support 10 No support No support

See also

Document Tags and Contributors

Contributors to this page: Sebastianz, AFBarstow, Sheppy
Last updated by: Sebastianz,