General
There are many scripts for copying text from a Web page that work fine in MS Internet Explorer but not in Firefox, Netscape, or Opera. This cross-browser script, however, will do the trick. It will copy a designated portion of text into the Windows clipboard, using a small Macromedia Flash file to perform the copy on the browser's behalf.
Notes
Created by:
Posted: July 11, 2007
Source Code
Paste this source code into the designated areas.
External file
Paste this code into an external JavaScript file named: clipboardCopy.js
Select code
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Mark O'Sullivan :: http://lussumo.com/
Jeff Larson :: http://www.jeffothy.com/
Mark Percival :: http://webchicanery.com/
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;
}
}
Head
Paste this code into the HEAD section of your HTML document.
Select code
<script type="text/javascript" src="clipboardCopy.js"></script>
Body
Paste this code into the BODY section of your HTML document
Select code
<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 type="button" value="Copy This" onclick="copy(document.form1.results.value);">
</form>
Other
Download the images using the URL below:
We'll send this script to you!
Do you write JavaScripts? If you do, why not submit them to us ? We'll give you credit and a link back to your Web site.