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 Quote Link to comment 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)"> Quote Link to comment 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.