Skip to main content
clipboardData object

Provides access to predefined clipboard formats for use in editing operations.


The clipboardData object has these types of members:


The clipboardData object has these methods.


(Deprecated as of Microsoft Edge.) Removes one or more data formats from the clipboard through the dataTransfer object. For the clipboardData object, this method clears all formats.


(Deprecated as of Microsoft Edge.) Gets the data in the specified format from the clipboard through the dataTransfer object or the clipboardData object.


(Deprecated as of Microsoft Edge.) Assigns data in a specified format to the dataTransfer object or the clipboardData object.



The clipboardData object has these properties.



Retrieves the local image files associated with a HTML paste operation (into an editable region of a web page).


Standards information

There are no standards that apply here.


The clipboardData object is reserved for editing actions performed through the Edit menu, shortcut menus, and shortcut keys. It transfers information using the system clipboard, and retains it until data from the next editing operation replaces it. This form of data transfer is particularly suited to multiple pastes of the same data.

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


This example uses the setData and getData methods with the clipboardData object to perform a cut-and-paste operation through the shortcut menu.

Code example:

var bResult;
// Select the text to be cut. Trailing spaces in a text
// selection in cut events cause the Cut shortcut menu item to
// remain disabled.
function fnLoad() {
    var r = document.body.createTextRange();
// Enable the Cut shortcut menu item over the div. Cut is disabled by default.
// Once Cut is enabled, Internet Explorer automatically copies the data to the
// clipboard and removes the selected text from the document.
function fnBeforeCut() {
    event.returnValue = false;
//Assign data in text format to the window.clipboardData object.
//Display the result (Boolean) from the setData method in the input box below.
function fnCut(){
	event.returnValue = false;
	bResult = window.clipboardData.setData("Text",oSource.innerText);
	oSource.innerText = "";
	tText.innerText += bResult;
// Enable the Paste shortcut menu item over the div. Paste is disabled by default.
function fnBeforePaste() {
    event.returnValue = false;
// Cancel the returnValue in onpaste for the text input, which
// has a default behavior.
function fnPaste() {
    event.returnValue = false;
	oTarget.innerText = window.clipboardData.getData("Text");
	LINK="#000000" VLINK="#808080" ALINK="#000000">
<div class="clsSource" ID="oSource" onbeforecut="fnBeforeCut()" oncut="fnCut()">
	Select and cut this text
<div class="clsTarget" ID="oTarget" onbeforepaste="fnBeforePaste()" onpaste="fnPaste()">
	Paste the Text Here
<span class="clsData">setData Result: </span>
<input class="clsText" ID="tText" TYPE="text" READONLY VALUE="" SIZE="6" TABINDEX="-1">

See also

Data Transfer Overview