HBCMS更多的中文手册参考:

clearData Method

DHTML文档教程

Removes one or more data formats from the clipboard through datatransfer or clipboarddata object.

dhtml语法

pret = object.cleardata( [sdataformat])

parameters

sDataFormat Optional. Stringthat specifies one or more of the following data format values:
TextRemoves the text format.
URLRemoves the URL format.
FileRemoves the file format.
HTMLRemoves the HTML format.
ImageRemoves the image format.

Return Value

No return value.

Remarks

If no sDataFormat parameter is passed, the data formats are cleared.

For drag-and-drop operations, the clearData method of the dataTransfer object is generally used in source events, such as ondragstart. when overriding the default behavior of the target, use cleardata in the ondrop event. it is particularly useful for selectively removing data formats when multiple formats are specified.

DHTML代码范例

This example uses the clearData method to remove the Text data format from the clipboard through the dataTransfer object.

<HEAD>
<STYLE>
DIV {background-color:magenta; width: 300;}
SPAN {color:lightgreen;}
</STYLE>
<SCRIPT>
function Source_DragStart(){
event.dataTransfer.setData("Text", "This text will be cleared");
}
function Target_Enter(){
window.event.returnValue = false;
event.dataTransfer.clearData("Text");
oTarget.innerText = event.dataTransfer.getData("Text");
}
</SCRIPT>
</HEAD>
<BODY>
<P>Drag the green text and drop it over the magenta DIV.</P>
<SPAN ID="oSource" ondragstart="Source_DragStart()">
Drag this text.
</SPAN>
<P>Drop the text below. The word "null" will appear in the DIV.</P>
<DIV
ID="oTarget" ondragenter="Target_Enter()">
</DIV>
</BODY>
This feature requires Microsoft® Internet Explorer 5 or later. Click the following icon to install the latest version. Then reload this page to view the sample.

是否符合公共标准

There is no public standard that applies to this method.

Applies To

clipboardData, dataTransfer

更多语法参考

about dhtml data transfer, getdata, setData