01.
<head>
02.
<script type=
"text/javascript"
>
03.
function
CopyToClipboard () {
04.
var
input = document.getElementById (
"toClipboard"
);
05.
window.clipboardData.setData (
"Text"
, input.value);
06.
}
07.
function
ShowClipboardContent () {
08.
var
input = window.clipboardData.getData(
"Text"
);
09.
alert(input);
10.
11.
document.getElementById(
"paste"
).value = input;
12.
}
13.
function
ClearClipboard () {
14.
window.clipboardData.clearData (
"Text"
);
15.
}
16.
</script>
17.
</head>
18.
<body>
19.
<input id=
"toClipboard"
value=
"text to clipboard"
/>
20.
<input id=
"paste"
name=
"paste"
value=
""
/>
21.
<button onclick=
'CopyToClipboard ()'
>
Copy
text to clipboard</button>
22.
<br /><br />
23.
<button onclick=
'ShowClipboardContent ();'
>Show text data in clipboard</button>
24.
<button onclick=
'ClearClipboard ();'
>Clear text data from clipboard</button>
25.
</body>