»
English French Vietnamese

Print - Copy to Clipboard using Flash - JavaScriptBank.com

Copy to Clipboard using Flash © JavaScriptBank.comOn the Internet in general and JavaScript in particular, there are many codes and tools to help your visitors copy text directly into the clipboard without through the browser or operating system. However, most restrict of these code are they only run on Internet Explorer, so you try to use this effect, it uses a Flash file to convert and perform the copy to the clipboard.

Full version: jsB@nk » Form » Copy to Clipboard using Flash



JavaScript
<script type="text/javascript">
<!--
/*
	Created by: Mark O'Sullivan :: http://lussumo.com/
	Jeff Larson :: http://www.jeffothy.com/
	Mark Percival :: http://webchicanery.com/
	Licensed under: GNU Lesser General Public License
*/

function copy(text2copy) {
  if (window.clipboardData) {
    window.clipboardData.setData("Text",text2copy);
  } else {
    var flashcopier = 'flashcopier';
    if(!document.getElementById(flashcopier)) {
      var divholder = document.createElement('div');
      divholder.id = flashcopier;
      document.body.appendChild(divholder);
    }
    document.getElementById(flashcopier).innerHTML = '';
    var divinfo = '<embed src="_clipboard.swf" FlashVars="clipboard='+escape(text2copy)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
    document.getElementById(flashcopier).innerHTML = divinfo;
  }
}
//-->
</script>


HTML
<form name="form1" action="">
  <textarea name="results" cols="40" rows="6">All
of the text here will be copied. Epsum factorial non deposit quid pro
quo hic escorol. Olypian quarrels et gorilla congolium sic ad nauseum.
Souvlaki ignitus carborundum.</textarea>
  <br>
  <input value="Copy This" onclick="copy(document.form1.results.value);" type="button">
</form>


Files
/javascript/form/Copy_to_Clipboard_using_Flash/_clipboard.swf