[HELP] COPY BUTTON
2015-06-16, 08:19 PM,
#1
Does anyone knows the code for Copy textarea text to clipboard for html that works in mobile browsers. A simple button, that when clicked copies the text in the textarea to the users clipboard. Thank you in advance.,
Reply
2015-06-16, 08:29 PM,
#2
Here you go mate.
Code:
<script type="text/javascript">

function CopyToClipboard()

{
CopiedTxt = document.selection.createRange();
CopiedTxt.execCommand("Copy");
}

</script>

<form name="Form1">
Here is some text you can copy. You can copy text from anywhere on the page, simply select it and press the Copy to clipboard button. Then you can paste it anywhere you want, in Notepad, Visual Studio or in the textarea below. <br />
<br />
<textarea id="txtArea" cols="60" rows="5">You can also copy text from this textarea. Or you can paste the text here, using the Ctrl+V key combination.</textarea>
<br />
<input type="button" onClick="CopyToClipboard()" value="Copy to clipboard" />
</form>

Fill in the details and your off to go
Latest Thanks - View all

noleecious(2015-06-16 08:34 PM) 
Reply
2015-06-16, 08:36 PM,
#3
Thanks for the response blachole, but i trie your script, but doest work both for mobile, and web, , maybe i missed something?
Reply
2015-06-16, 08:42 PM,
#4
(2015-06-16, 08:36 PM)noleecious Wrote: Thanks for the response blachole, but i trie your script, but doest work both for mobile, and web, , maybe i missed something?

I got this from StackOverFlow. Look around google, There are tons.

Here: http://www.googleautobot.com/?q=Copy+button+Code
Reply
2015-06-16, 08:43 PM,
#5
i did google it 1st before asking here. . . still struggling.
Reply
2015-06-17, 06:51 AM,
#6
That does not exist. Only flash method to copy texts
Reply
2015-06-17, 03:34 PM,
#7
You can try this http://zeroclipboard.org/
Latest Thanks - View all

noleecious(2015-06-17 06:10 PM) 

|PHP|JAVASCRIPT|HTML|CSS|
skype: milovan.panic92
Reply
2015-06-17, 06:47 PM,
#8
(2015-06-17, 03:34 PM)MIG92 Wrote: You can try this /

thanks MIG92, it works for webrowsers but not for mobile. Thanks.
Reply
2015-06-17, 11:28 PM,
#9
(2015-06-17, 06:47 PM)noleecious Wrote:
(2015-06-17, 03:34 PM)MIG92 Wrote: You can try this /

thanks MIG92, it works for webrowsers but not for mobile. Thanks.

No problem,I am not sure you can do it for mobile devices,i would stay away from using that...Coz' you can loose many users,if your site isn't working as it should... :)

|PHP|JAVASCRIPT|HTML|CSS|
skype: milovan.panic92
Reply
2015-06-18, 04:50 PM,
#10
if javascript is enabled, this should copy the text from the textarea when the user moves out of the textarea, so you can either create a button that is just there so the user does an action outside of the textarea or you change the "onblur" and add a button that does the same action onclick but then you will need to pass the text

Code:
<body>
    <textarea rows="5" cols="20" wrap="hard" onblur="CopyToClipboard(this)"></textarea>
</body>

<script language="JavaScript">
function CopyToClipboard(text) {
    Copied = text.createTextRange();
    Copied.execCommand("Copy");
}
</script>

tell me if it works maybe i will need it someday xD
Latest Thanks - View all

noleecious(2015-06-18 06:52 PM) 
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Button + iframe hopsa 3 186 2017-09-21, 07:18 PM
Last Post: FlyingCactus
  Mobile traffic redirect after clicks on button Warriorcpa 2 1,091 2016-10-01, 05:54 PM
Last Post: Warriorcpa
  i need help in button Cpagrip vip2 6 996 2015-11-24, 07:38 PM
Last Post: SiriusBlack
  Facebook share button locker neroazzurro 2 817 2015-11-05, 02:01 AM
Last Post: SiriusBlack
  Landing page + Button Ben””” 2 630 2014-07-19, 03:24 AM
Last Post: DutchPride




About Us | Contact Us | CPA Elites | Advertise | Stats | Staff Team

© 2013-2017 CPA Elites Ltd
Enhanced by MyBB and WallBB
Return to top