http://sufikatha.com
Nishanth's Blog | January 2009

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

by Nishanth 26. January 2009 18:35

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();

range.addElement(document.getElementById('divLink'));

range.select();

range.execCommand("Copy");

range.remove(0);

range.select();

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

div.contentEditable = false; 

return false;

}

Currently rated 3.0 by 4 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

All Good Websites

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About Me

Nishanth Nair  

 A die hard fan of Rise of Nations... I write few softwares for McAfee Inc. for a living.

 

Portfolio:
http://Necab.org
http://SufiKatha.com
http://DeepaRecipes.com
http://ManipalFoundation.in
http://NetraArts.com
http‌://EnWebTech.com
Contact : Nair.Nishanth@Gmail.com 

All entries in this blog are my opinion and don't necessarily reflect the opinion of my employer.

Tag cloud

The World This Second

free counters