免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1868 | 回复: 1
打印 上一主题 下一主题

JavaScript操作剪贴板 - ( for IE ) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-06 19:14 |只看该作者 |倒序浏览
JavaScript操作剪贴板 - ( for IE )













bRet = [window.]clipboardData.clearData(['Text' | 'URL' | 'File' | 'HTML' | 'Image'])
sData = [window.]clipboardData.getData('Text' | 'URL')
bAdded = [window.]clipboardData.setData('Text' | 'URL', sData)





下面为来自MSDN的内容:

参见:

http://msdn.microsoft.com/en-us/vstudio/ms536352%28VS.85%29.aspx

http://msdn.microsoft.com/en-us/vstudio/ms536436%28v=VS.85%29

http://msdn.microsoft.com/en-us/vstudio/ms536744%28v=VS.85%29



clearData Method

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

Syntax

        pret = object.clearData( [sDataFormat])

Parameters

    sDataFormat    Optional. A String that specifies one or more of the following data format values.

    Text
        Removes the text format.
    URL
        Removes the URL format.
    File
        Removes the file format.
    HTML
        Removes the HTML format.
    Image
        Removes the image format.

Return Value

    A Boolean value indicating success or failure.
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 used generally in source events, such as ondragstart. When you override 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.
   
getData Method

Gets the data in the specified format from the clipboard through the dataTransfer object or the clipboardData object.

Syntax

        sRetrieveData = object.getData(sDataFormat)

Parameters

    sDataFormat    Required. A String that specifies one of the following data format values.

    Text
        Gets data formatted as text.
    URL
        Gets data formatted as a URL.

Return Value

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

Remarks

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

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


setData Method

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

Syntax

        bSuccess = object.setData(sDataFormat, sData)

Parameters

    sDataFormat    Required. A String that specifies the format of the data to be transferred, using one of the following values.

    Text
        Transfers data formatted as text.
    URL
        Transfers data formatted as a URL.

    sData    Required. A String that 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 that is transferred.

Return Value

    Boolean. Returns one of the following possible values.

    true
        The data was successfully added.
    false
        The data was not added.

Remarks

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

论坛徽章:
0
2 [报告]
发表于 2011-12-24 20:57 |只看该作者
飘过啦............
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP