Top

Copy to Clipboard Javascript

Please Register to submit score.
Average Score  7.0
Scores Submitted  2
Date Added  Mar 24, 2007
Last Updated  Mar 24, 2007
Tags  clipboard  copy 

Introduction

This will copy the text in a given field to the clipboard. Unfortunately it only works in IE, so Firefox users will still need to do the actual copy. But it'll at least select the text for Firefox users.

Here is how you set up your HTML:

Code:
<form name=myform>
<input type=text name=mytext value='This text will be copied'>
<input onclick="javascript:copyToClipboard('myform.mytext')" type="button" value="Send to Clipboard">
</form>


You can name the form and text box anything you'd like. Just be sure to send the proper parameters to the copyToClipboard function. You may also use a textarea like we do here for our snippets.

Grab the Code

Comments

  (2)  RSS
M[n]M
Comments: 95
 
Javascript Snippet:  Copy to Clipboard Javascript
Posted on Oct 4, 2007 2:18 pm
nice thats what i was searching for!
markusPHP
Comments: 8
 
Javascript Snippet:  Copy to Clipboard Javascript
Posted on Jun 16, 2008 11:58 am
Works in Opera, you might add.

Please Register or Login to start posting comments.
Bottom