Copy to Clipboard

In this board you can talk about general questions about phpMyFAQ

Moderator: Thorsten

Post Reply
sergey.khodjamirian
Posts: 35
Joined: Wed Aug 09, 2006 11:36 am

Copy to Clipboard

Post by sergey.khodjamirian »

Hi guys,

I am trying to add a Copy to Clipboard function, so that when viewing a record and clicking a button, it copies the answer to the clipboard. Here are the changed that I have made. Please tell me if I am doing anything wrong:



##########################################################
Templates/artikel.tpl
##########################################################

--------ADDED------------

<img src="images/copy.gif" alt="{writeCopyToClipboard}" title="{writeCopyToClipboard}" width="16" height="16" border="0" /> {writeCopyClipboard}

--------ADDED-----------

+

---------ADDED----------

<!-- Article -->
<SPAN ID="copytext"> <p>{writeContent}</p> </SPAN>
<!-- /Article -->

<TEXTAREA ID="holdtext" STYLE="display:none;">
</TEXTAREA>

---------ADDED----------


##########################################################
artikel.php
##########################################################


------ADDED-------------

$copyClipboard = sprintf(
'<SCRIPT LANGUAGE="JavaScript">function ClipBoard()
{
holdtext.innerText = copytext.innerText;
Copied = holdtext.createTextRange();
Copied.execCommand("RemoveFormat");
Copied.execCommand("Copy");
}
</SCRIPT>
<a href="#" onclick:"ClipBoard();">%s</a>',
$PMF_LANG['msgCopyToClipboard']);

----ADDED----------------

+

-------ADDED-------------

"writeCopyToClipboard" => $PMF_LANG["msgCopyToClipboard"],
"writeCopyClipboard" => $copyClipboard,

--------ADDED-----------

##########################################################
copy.gif to Images/
##########################################################
lang/language_en
##########################################################

-------ADDED------------

$PMF_LANG["msgCopyToClipboard"] = "Copy to Clipboard";

-------ADDED-----------

##########################################################
matteo
Posts: 572
Joined: Sun Nov 20, 2005 6:53 pm
Location: Italy

Post by matteo »

Hi Sergey,
when you view the printed out HTML from your browser, do you see any error?

PS: if you email me a zipped file with both artikel.php and artikel.tpl I can test it too.
phpMyFAQ QA / Developer
Amazon.co.uk Wishlist
sergey.khodjamirian
Posts: 35
Joined: Wed Aug 09, 2006 11:36 am

Post by sergey.khodjamirian »

Matteo

I sent you the stuff, so give it a try please. I havent tried it yet, because i have limited access to the server (ive explained it to you in the e-mail)

thanks!
matteo
Posts: 572
Joined: Sun Nov 20, 2005 6:53 pm
Location: Italy

Post by matteo »

Hi Sergey,
I look at it within few hours: in the mean time I've seen that the JS code seem to be quite right 'cause it is equal to that found on http://www.htmlgoodies.com/beyond/javas ... hp/3458851, where it works.
I'll reply both to you by email with the working code and here with some info for Community convenience.

Regards,
Matteo
phpMyFAQ QA / Developer
Amazon.co.uk Wishlist
fabio.sampo
Posts: 1
Joined: Mon Nov 18, 2013 9:20 am

Re: Copy to Clipboard

Post by fabio.sampo »

hello everyone, I'm new to the forum. I tried to put this code, but I do not work. Can anyone help me? thanks to all
Post Reply