Ultra fast cheap  linux and windows hosting
javascript tutorial Browse Basic JavaScript Tutorial
Browse JavaScript Script resources
Browse javascript FAQS

javascript tutorial
buy template
Home >> Tutorials >> Advanced javascript tutorials

Copy text To Clipboard

This example will copy text on the page to the clipboard (then try using the menu to paste...)

function CopyToClipboard()
  obj = null;

  if (obj) { window.clipboardData.setData('Text', obj.innerText); }


  document.write(" <a href='javascript:CopyToClipboard()'>Copy Example Code to your Clipboard</a>");

<table border=1>
<tr><td><span id='the_code'> 

This example will 
copy text in the table to the clipboard (then try using the menu to paste...) 














Explanation of code:

(1) When you click on the link Copy Example Code to your Clipboard function CopyToClipboard() will be called. In this function getElementById() method returns the first occurrence of the ID attribute value, the_code.

(2) Then setData method of clipboardData object assigns data in a specified format to the clipboardData object .

Page contents: itechies.net - Copy text To Clipboard
javascript tutorial
javascript book
Buy this book