HTML and CSS Reference
In-Depth Information
FIGURE 8.3 Dragged content
from my web page creates a
desktop text snippet.
One fi nal note about setData : It only accepts strings. This
means you can't store a “complex” JavaScript object in a con-
tent type. However there's an easy enough solution around this:
JSON.stringify .
All the latest browsers ship with native JSON encoding ( stringify )
and decoding ( parse ), so you can stringify our complex object
and set it against a content type. For the older browsers you
can include the JSON library from http://json.org/json2.js
(though host it yourself as there's a nice little alert box you'll
need to remove that prevents hotlinking), which will plug sup-
port for JSON stringify and parse .
Problems with setting drag data
Native desktop applications have had drag and drop for some
time now and have had years to get the APIs right. One huge
advantage that native applications have is that the setting of
data doesn't actually happen, or execute, when the user starts
dragging. It happens when the user drops.
There is an important reason for this: When you drop, you only
need one content type.
 
Search WWH ::




Custom Search