Tuesday, March 21, 2006

How to get the ClipBoard Contents

I had received a mail from Praveen Some time back. The mail was related to the Clipboard contents which can be copied by certian Websites if you access those sites.

I thought why not experiment on this. As I thought there came two possibilities:

1.Java code which would access the clipboard of the client's computer.
2.The scripting languages which have immense Power, by certain API's one can access the clipboard contents of the client machine. And it would also be easier as the Scripts run on the client's machine itself.

I thought of the 2nd idea, here I give you simple code which will display your last contents of the clipboard. These contents can also be passed to the Server (so called websites).

Just write an Html file and check it yourself.

try.html


<script language="JavaScript" >
function display() {
var cbData = window.clipboardData.getData('Text');
alert(cbData);
}
</script>
Click the Button to Know your ClipBoard Contents
<input type="button" value = "Click Me for Information"
onClick="javascript:display()" >

No comments:

Java 10 Features

My blog post in JournalDev for Java 10 Features