Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » JavaScript - Copying Pre-defined Text to Clipboard
Closed Thread
Old 04-03-2005, 06:39 AM   #1 (permalink)
 
Monster Techie

Join Date: May 2004

Location: Tucson, AZ, USA

Posts: 1,183

Vormund

Send a message via AIM to Vormund Send a message via MSN to Vormund Send a message via Yahoo to Vormund
Question JavaScript - Copying Pre-defined Text to Clipboard

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.
__________________
Vormund is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On