Hey,
I need a javascript that can allow a user to highlight text on a webpage and then click a button and the text that is selected would be copied to the clipboard.
Anysuggestions or help?
Maybe this could be used:
Description: This “demo” script does two things: 1) identifies the selected text on the page 2) copies this text to clipboard. As part of a larger application, it is useful wherever text needs to be rapidly and instantly copied.
[url]http://www.dynamicdrive.com/dynamicindex11/copytext.htm
[code=php]<script>
//Copytext to clipboard- by Gennero ([email protected])
//Submited to DynamicDrive.com
//Visit [url]http://www.dynamicdrive.com[/url] for this script
bBool=false
var copiedtext=””
var tempstore=””
function initiatecopy() {
bBool=true;
}
function copyit() {
if (bBool) {
tempstore=copiedtext
document.execCommand(“Copy”)
copiedtext=window.clipboardData.getData(“Text”);
if (tempstore!=copiedtext) {
alert(copiedtext);
}
bBool=false;
}
}
document.onselectionchange = initiatecopy
document.onmouseup = copyit
</script>