Home | Top | Free Ajax Editor | JavaScript Editor JavaScript EditorGet Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.


getData Method

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

Syntax

sRetrieveData = object .getData( sDataFormat )

Parameters

sDataFormat Required. String  that specifies one of the following data format values:
Text Retrieves data formatted as text.
URL Retrieves 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.

 

<HEAD> <SCRIPT> function InitiateDrag(){ event.dataTransfer.setData(oSource.innerText); } function FinishDrag(){ window.event.returnValue=false; oTarget.innerText = event.dataTransfer. getData ("Text"); } function OverDrag(){ window.event.returnValue=false; } </SCRIPT> </HEAD> <BODY> <B ID="oSource" ondragstart="InitiateDrag()"> drag this text</B> <SPAN ID="oTarget" ondragover="OverDrag()" ondragenter="FinishDrag()""> drop text here</SPAN> </BODY>

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

 

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

Standards Information

There is no public standard that applies to this method.

Applies To

[ Object Name ] Platform Version
Win16:
Win32:
Unix:
Mac:
Windows CE:
 
clipboardData , dataTransfer
Home | Top | Free Ajax Editor | JavaScript Editor JavaScript EditorGet Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.