112 | Chapter 4: AIR Mini-Cookbook
<html>
<head>
<title>HTML Drag Test</title>
<script src="AIRAliases.js" />
<script>
// DROP EVENTS
function onDragEnter(event)
{
air.trace("onDragEnter");
event.dataTransfer.dropEffect = "copy";
event.preventDefault( );
}
function onDrop(event)
{
air.trace("onDrop");
air.trace( event.dataTransfer.getData("text/plain") );
air.trace( event.dataTransfer.getData("text/uri-list") );
}
function onDragOver(event)
{
event.preventDefault( );
}
// DRAG EVENTS
function onDragStart(event)
{
air.trace("onDragStart");
event.dataTransfer.setData("text/plain",
"This is the URL I am dragging" );
// We overwrite the default URL specified in the
// anchor tag with a different URL. When the data
// is dropped, this is the URL that will be
// transferred.
event.dataTransfer.setData("text/uri-list",
"http://www.foo.com" );
event.dataTransfer.effectAllowed = "all";
}
function onDragEnd( event )
{
air.trace("onDragEnd");
}