Pegasus3245 Posted September 30, 2012 Share Posted September 30, 2012 Hi Everyone, I have a text box, with an address which visitors need to copy into another application. I have the text box, this has the text inside. All I need now is a button that says 'copy' and when you click it, wola! However, the real world hasnt worked this way for me . The code I have is; <script type="text/javascript"> function ClipBoard() { if (window.clipboardData) { alert("copied"); window.clipboardData.setData("Text",document.form1.name.value); } } </script> <form name="form1" method="post" action=""> <input name="name" type="text" class="inputtext" onclick="highlight(this)" id="name" value="<?php echo "$contents";?>"> <BUTTON onclick="ClipBoard()">Copy</BUTTON> </form> I dont understand why this wont work... Any help would be greatly apreciated. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/268933-copy-to-clipboard/ Share on other sites More sharing options...
Pegasus3245 Posted September 30, 2012 Author Share Posted September 30, 2012 I dont know why, but its suddenly started working.... Anyone is welcome to use the above if they need it. But I believe it will only work in Internet Explorer, not opera, mozilla etc. Quote Link to comment https://forums.phpfreaks.com/topic/268933-copy-to-clipboard/#findComment-1381881 Share on other sites More sharing options...
Christian F. Posted September 30, 2012 Share Posted September 30, 2012 A quick search online gave me this page, amongst others: http://www.jquery4u.com/plugins/jquery-copy-clipboard-4-options/#.UGhB-BrmPgc Quote Link to comment https://forums.phpfreaks.com/topic/268933-copy-to-clipboard/#findComment-1381891 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.