dataTransfer Object > script

본문 바로가기

script

dataTransfer Object

작성일 06-09-12 17:18

페이지 정보

작성자서방님 조회 376회 댓글 0건

본문

dataTransfer Object

Provides access to predefined clipboard formats for use in drag-and-drop operations.

Attributes/Properties
* dropEffect : Sets or retrieves the type of drag-and-drop operation and the type of cursor to display.
* effectAllowed :Sets or retrieves, on the source element, which data transfer operations are allowed for the object.

Methods
* clearData : Removes one or more data formats from the clipboard through dataTransfer or clipboardData object.
* getData :  Retrieves the data in the specified format from the clipboard through the dataTransfer : or clipboardData objects.
* setData : Assigns data in a specified format to the dataTransfer or clipboardData object.

Remarks

The dataTransfer object makes it possible to customize the handling of drag-and-drop operations. It is available through the event object.

The dataTransfer object is used in source and target events. Typically, the setData method is used with source events to provide information about the data being transferred. In contrast, the getData method is used with target events to stipulate which data and data formats to retrieve.

This object is available in script as of Microsoft Internet Explorer 5.

Example

This example uses the setData and getData methods of the dataTransfer object to perform a drag-and-drop operation.

<HEAD>
<SCRIPT>
var sAnchorURL;

function InitiateDrag()
/*  The setData parameters tell the source object
    to transfer data as a URL and provide the path.  */

{  
    event.dataTransfer.setData("URL", oSource.href);
}

function FinishDrag()
/*  The parameter passed to getData tells the target
    object what data format to expect.  */

{
    sAnchorURL = event.dataTransfer.getData("URL")
    oTarget.innerText = sAnchorURL;
}
</SCRIPT>
</HEAD>
<BODY>
<A ID=oSource HREF="about:Example_Complete" onclick="return(false)"
   ondragstart="InitiateDrag()">Test Anchor</A>
<SPAN ID=oTarget ondragenter="FinishDrag()">Drop the Link Here</SPAN>
</BODY>

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/jscript7/html/jsobjobject.asp

첨부파일

댓글목록

등록된 댓글이 없습니다.

게시물 검색
Copyright © 서방님.kr All rights reserved.
PC 버전으로 보기