Removes one or more data formats (or all data) from the clipboard through the DataTransfer object or the ClipboardData object.
Method of dom/DataTransferdom/DataTransfer
Syntax event.dataTransfer.clearData(format);
Parameters format
(Optional)
The format of the data to be cleared, using one of the following values (case insensitve):
If format is omitted, all data is removed.
Return ValueNo return value
ExamplesThis example uses the clearData, setData, and getData methods with the DataTransfer object.
<!doctype html>
<html>
<head>
<script>
var sImageURL, oTarget, oImage;
function initiateDrag(e) {
e.dataTransfer.setData("URL", oImage.src);
}
function finishDrag(e) {
e.dataTransfer.clearData("URL");
oTarget.textContent = e.dataTransfer.getData("URL");
}
function initialize() {
oImage = document.getElementById("oImage");
oTarget = document.getElementbyId("oTarget");
oImage.addEventListener("dragstart", initiateDrag, false);
oTarget.addEventListener("dragenter", finishDrag, false);
}
window.addEventListener("load", initialize, false);
</script>
</head>
<body>
<p>This example demonstrates how to use the setData and getData methods of the dataTransfer object to enable the source path of the image to be dragged. Since we are clearing the data, dragging over the target will show "null" instead.</p>
<img id="oImage" src="/workshop/graphics/black.png" width="20" height="20" alt="Black">
<span id="oTarget">
Drop the image here
</span>
</body>
</html>
Notes
Microsoft Developer Network: [Windows Internet Explorer API reference Article]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4