JavaScript - Copying Pre-defined Text to Clipboard

Status
Not open for further replies.

Vormund

Daemon Poster
Messages
1,178
Location
USA
Anyone know how to copy text to the clipboard that is predefined?

<script language="JavaScript">
<!--
function CopyToClipBoard(post) {
polka = createTextRange(post);
polka.execCommand("Copy");
}
-->
</script>

is what I want, but that is apparently not working/I'm doing something wrong/haven't used javascript much...

all the examples online use forms for the data, such as:

function copyText(theText) {
var tempval=eval("document."+theText)
tempval.focus()
tempval.select()
therange=tempval.createTextRange()
therange.execCommand("Copy")
alert("Text copied into the clipboard!");

but I want to do it purely with the data passed through the value 'post'...

Anyone have any ideas?

thanks.
 
Status
Not open for further replies.
Back
Top Bottom