You need to sign in to do that
Don't have an account?
Jeremy_n
Copy to Clipboard Button
Has anyone successfully created a "Copy to Clipboard" button in Visualforce?
I've got a method that works for Internet Explorer only ( http://www.htmlgoodies.com/beyond/javascript/article.php/3458851/Click-Its-Copied.htm) , which will be acceptable at this point, although I would prefer a cross-browser solution.
However, I don't seem to be able to make it work in a VF page. Here's my basic attempt:
<apex:page title="Clipboard Test" showheader="false"> <script language="JavaScript"> function ClipBoard() { holdtext.innerText = {!$Component.copytext}.innerText; Copied = holdtext.createTextRange(); Copied.execCommand("Copy"); } </script> <body > <apex:outputpanel ID="copytext" > This text will be copied onto the clipboard when you click the button below. </apex:outputpanel> <TEXTAREA ID="holdtext" STYLE="display:none;"> </TEXTAREA> <BUTTON onClick="ClipBoard();">Copy to Clipboard</BUTTON> </body> </apex:page>
I am not a Javascript expert, which is making this all harder for me. Please help!
Thanks,
Jeremy
Well, I've got it working. Here is an example Visualforce page that incorporates javascript to copy specified text to the Windows clipboard.I'm posting it in case anyone else wants to do this again.
NOTE: This only works on Internet Explorer. it makes use of IE-only javascript extensions. To do the same thing in a standards-based browser is more complicated, and will require some other technology, like Flash.
Basic example:
There you go,
Jeremy
All Answers
Well, I've got it working. Here is an example Visualforce page that incorporates javascript to copy specified text to the Windows clipboard.I'm posting it in case anyone else wants to do this again.
NOTE: This only works on Internet Explorer. it makes use of IE-only javascript extensions. To do the same thing in a standards-based browser is more complicated, and will require some other technology, like Flash.
Basic example:
There you go,
Jeremy
Copy is working great with following code on custom button click:
But, it is not working for first time with following code(working on second click):
Any help on why it is failing if we are using {!REQUIRESCRIPT('/resource/jquery')} ?
Thanks in advance!
pavan.elthepu1.392651269495206E12 - were you able to resolve the 1st click copy?
We are running into the same issue.