Logo
  Sunday, May 20, 2012
Sign-In  |  Sign-Up  |  Contact Us  | Bookmark |  RSS Feed

HTML5 Tutorial FeedBurner

HTML5 dataTransfer object  
The HTML5 dataTransfer object is part of drag and drop feature in HTML5. It is the main object that holds information about object being dragged and dropped. Moreover, it is available to every single drag and drop event in HTML5.

In order to retrieve dataTransfer object we need to handle drag event. The following code shows you how it is done in HTML5.

The HTML5 dataTransfer is used to set and obtain the drop data during communication between target and source. There are several functions and properties available as a part of the HTML5 dataTransfer object.

<script>

function handleDragEvent(evt)

{

    var myTransferObject = evt.dataTransfer;  

}

</script>

  • setData(format, data) – registers data with MIME type
  • getData(format) – allows for data retrieval
  • clearData() – clears out all data
  • setDragImage(element, x, y) – commands browser to use existing image. X and y are coordinates of the drop location
  • addElement(element) – commands browser to draw element as a drag image
  • types – array of all registered formats
  • items – list of items and their formats
  • files – file associated with the drop
  • effectAllowed – commands browser to use only listed commands. This property can be set to: none, copy, copyLink, copyMove, link, linkMove, move, or all
  • dropEffect – determines operation currently being executed
Print HTML5 dataTransfer object Bookmark HTML5 dataTransfer object

Related Articles  
HTML5 Custom Tags
The HTML5 allows you to customize an input tag. The HTML input tag can be modified to allow custom validation in a more ...
HTML5 Form Input Types
HTML5 forms have new set of input types in addition to well known and widely used input types such as text, checkbox, ...
Adding HTML5 Spellcheck to the HTML5 Form
The W3C's HTML5 specification added HTML5 spellcheck attribute to input and textarea elements of the HTML5 web page.
HTML5 Drag and Drop Key Concepts
HTML5 Drag and Drop is modeled after desktop based application. As a result, HTML5 drag and drop is easy to implement ...
Adding Placeholder Text in HTML5 Input Fields
HTML5 has new way of adding this text via input attribute called "placeholder". You can assign text to this placeholder ...
HTML5 Email Input Type Tag
HTML5 introduced several new input types. On the important types is email input type. HTML5 Email Input type creates a ...
More