HTML and CSS Reference
In-Depth Information
Interoperability of dragged data
By using the setData and getData methods on the dataTransfer
object, we can pass data from elements inside our applica-
tion to other pages of our app, or across browser windows—as
280 Slides has prototyped, when dragging one slide from one
window to another completely separate document ( Figure 8.2 ).
Yo u   c a n a l s o a c c e p t o r s e n d d a t a t o n a t i v e d e s k t o p a p p l i c a t i o n s .
FIguRE 8.2 An early
prototype of how drag and drop
could work in 280 Slides.
Dragging data to other applications
So long as you know what the accepted content types are, you
can set the data type to accept that particular content type. For
example, on a Macintosh, it's possible to drag text snippets to the
desktop. I can construct my own content, set the content type to
text/plain, and when I drag the text to the desktop, a text snippet
is created with my content ( Figure 8.3 ):
img.ondragstart = function (event) {
event = event || window.event;
// here be one long line
event.dataTransfer.setData('text/plain',
'This is the screen name for ' + this.getAttribute
¬ ('data-screen_name') +
', whose image can be found here: ' + this.src);
};
 
 
Search WWH ::




Custom Search