Skip to content

Other - Native HTML, Text & URLs

The target below accepts BdndNativeTypes.Html, BdndNativeTypes.Text and BdndNativeTypes.Url. Select some text on another page (or in the box on the right) and drag it here, or drag a link / image - the dropped HTML, plain text and any URLs are read from the native DataTransfer. The HTML is shown as text: dropped markup is untrusted input, to be sanitized before it is ever rendered. The box below the target goes the other way: its NativeData is what it carries out of the page.

Drag selected text / a link here

Try selecting and dragging this rich text with a link inside.

Drag me into a text editor, or onto another tab's address bar
Text only Dropped around the field: nothing yet
The payload is read during the drop, the only moment the browser allows it. While a drag hovers, ItemType tells which of the accepted types matched first, in the order the target lists them; Data holds the string of every accepted type the drag carried, and Text, Html, Url and Urls are shortcuts into it. A target reads only the types it accepts: the last one takes BdndNativeTypes.Text, so a drag's HTML is never read there. Its text field shows how a target treats an editable field inside it: a text drag over the field is left to the browser, so dropped on the field the text goes into the field as it would anywhere; dropped on the rest of the target, it reaches OnNativeDrop. Inside the page, the "drag me" box's drag stays the in-app drag it is - neither target takes it for native text - but a text editor, another application or another tab's address bar read its NativeData.
An unhandled error has occurred. Reload 🗙