clipboardData 对象

下面的表格列出了 clipboardData 对象引出的成员。请单击左侧的标签来选择你想要查看的成员类型。
方法:

方法描述
clearData通过 dataTransferclipboardData 对象从剪贴板删除一种或多种数据格式。
getData通过 dataTransferclipboardData 对象从剪贴板获取指定格式的数据。
setData以指定格式给 dataTransferclipboardData 对象赋予数据。

clearData Method

Internet Development Index


Removes one or more data formats from the clipboard through dataTransfer or clipboardData object.

Syntax

pret = object.clearData( [sDataFormat])

Parameters

sDataFormatOptional. 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.

Example

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

SHOWExample

Standards Information

There is no public standard that applies to this method.

Applies To

[ Object Name ]
PlatformVersion
Win16: 
Win32: 
Unix: 
Mac: 
Windows CE: 
Version data is listed when the mouse hovers over a link, or the link has focus.
clipboardData, dataTransfer
Move the mouse pointer over an element in the Applies To list to display availability information for the listed platforms.

See Also

About DHTML Data Transfer, getData, setData

getData Method

Internet Development Index


Retrieves the data in the specified format from the clipboard through the dataTransfer or clipboardData objects.

Syntax

sRetrieveData = object.getData(sDataFormat)

Parameters

sDataFormatRequired. Stringthat specifies one of the following data format values:
TextRetrieves data formatted as text.
URLRetrieves data formatted as a URL.

Return Value

String. Returns the data in the format retrieved from clipboard through the dataTransfer or clipboardData object. Depending on the information contained in setData, this variable can retrieve a path to an image, text, or an anchor URL.

Remarks

The getData method enforces cross-frame security and allows data transfers within the same domain only. To the user this means that dragging a selection between different security protocols, such as HTTP and HTTPS, will fail. In addition, dragging a selection between two instances of the browser with different security levels, where the first instance is set to medium and the second is set to high, will fail. Finally, dragging a selection into the browser from another drag-enabled application, such as Microsoft® Word, also will fail.

To use the getData method to retrieve data from the clipboard within the oncopy or oncut event, specify window.event.returnValue=false within the event handler script.

Examples

The following examples use the setData and getData methods of the dataTransfer object to drop text in a new location and create a desktop shortcut.

This example uses the getData method to drag text and drop it in a new location.

SHOWExample

This example uses the getData method to create a desktop shortcut using a drag-and-drop operation.

SHOWExample

Standards Information

There is no public standard that applies to this method.

Applies To

[ Object Name ]
PlatformVersion
Win16: 
Win32: 
Unix: 
Mac: 
Windows CE: 
Version data is listed when the mouse hovers over a link, or the link has focus.
clipboardData, dataTransfer
Move the mouse pointer over an element in the Applies To list to display availability information for the listed platforms.

See Also

About DHTML Data Transfer, clearData, setData

setData Method

Internet Development Index


Assigns data in a specified format to the dataTransfer or clipboardData object.

Syntax

bSuccess = object.setData(sDataFormat, sData)

Parameters

sDataFormatRequired. Stringthat specifies the format of the data to be transferred, using one of the following values:
TextTransfers data formatted as text.
URLTransfers data formatted as a URL.
sDataRequired. Stringthat specifies the data supplied by the source object. This information can be descriptive text, a source path to an image, or a URL for an anchor. When you pass "URL" as the sDataFormat parameter, you must use the sData parameter to provide the location of the object being transferred.

Return Value

Boolean. Returns one of the following possible values:

trueThe data was successfully added.
falseThe data was not added.

Remarks

The value of the sDataFormat parameter is not case-sensitive.

Example

This example uses the setData and getData methods with the dataTransfer object to create a shortcut to an image.

SHOWExample

Standards Information

There is no public standard that applies to this method.

Applies To

dataTransfer
PlatformVersion
Win16:5
Win32:5
Unix:5
Mac:5
Windows CE:5.5
clipboardData, dataTransfer
Move the mouse pointer over an element in the Applies To list to display availability information for the listed platforms.

See Also

About DHTML Data Transfer, clearData, getData
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值