Function in javascript to copy text area to client machine's clipboard

Here  is a small JS snippet to copy text in a div to the client machine's  clipboard.

function CopyToClipBoard()


var div = document.getElementById('divLink');

div.contentEditable = true; //very important.

var range = document.body.createControlRange();




alert("The results have been copied to the clipboard.");

div.contentEditable = false; 

return false;



Do you have any more info on this?

Searching for this for some time now – i guess luck is more advanced than search engines 🙂

thanks! very helpful post!! like the template btw 😉

Interesting … as always – is your blog making any cash advance ? 😉

I don’t like your template but your posts are quite good so I will check back!

When sorrows come, they come not single spies, but in battalions.

Leave a reply