npsari Posted May 3, 2007 Share Posted May 3, 2007 Posted: Wed May 02, 2007 10:19 pm Post subject: Instant Text copy button -------------------------------------------------------------------------------- The below script allows text copy in a click of a button: Try it out, it is nice actually <script type="text/javascript"> function cmdA(el) { with(el){ focus(); select(); } if(document.all){ txt=el.createTextRange() txt.execCommand("Copy") window.status='Selected and Copied to Clipboard!' document.WordForm.cpyButton.value="Copied!"; setTimeout("WordForm.cpyButton.value='Copy'",1000) } else window.status='Press Ctrl-C to Copy the Text to the Clipboard' setTimeout("window.status='WebTv users you must Press Cmd & C !'",3000) } </script> <form name="WordForm" > <input type="text" id="Editbox1" size="30" name="Screen" value="Yo wassup dudeee"> <input type="button" width="120" NAME="cpyButton" value="Copy" onClick="cmdA(document.WordForm.Screen)"> However, when the button is clicked, another button shows with the word copied! Can someone show me how can the script display an image (/images/copied.gif) instead of the button. Your support is appreciated npsari Link to comment https://forums.phpfreaks.com/topic/49788-instant-text-copy-button/ Share on other sites More sharing options...
Cory94bailly Posted August 4, 2008 Share Posted August 4, 2008 Hey sorry for the late reply but what the hell. Here: <script type="text/javascript"> function cmdA(el) { with(el){ focus(); select(); } if(document.all){ txt=el.createTextRange() txt.execCommand("Copy") window.status='Selected and Copied to Clipboard!' <img src="/images/copied.gif" alt="Copied!" /> setTimeout("WordForm.cpyButton.value='Copy'",1000) } else window.status='Press Ctrl-C to Copy the Text to the Clipboard' setTimeout("window.status='WebTv users you must Press Cmd & C !'",3000) } </script> <form name="WordForm" > <input type="text" id="Editbox1" size="30" name="Screen" value="Yo wassup dudeee"> <input type="button" width="120" NAME="cpyButton" value="Copy" onClick="cmdA(document.WordForm.Screen)"> Link to comment https://forums.phpfreaks.com/topic/49788-instant-text-copy-button/#findComment-607932 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.