Jump to content

Copy Button?


Perad

Recommended Posts

Hi there,

 

Could someone help me with a copy button?

 

This is my html.

 

<table border="1" cellSpacing="2" cellPadding="1" width="341" align="center" height="64">
<tbody>
	<tr>
		<td height="54" width="151">
			<img border="0" src="http://gotyou.co.uk/wp-content/uploads/2009/04/copy-button.jpg" onclick="copyit()" width="112" height="32">
		</td>
		<td height="50" width="100%">
			<textarea id="copy" style="width:450px; height:70px; font-size:10px; overflow:hidden;"><embed src='http://gotyou.co.uk/wp-content/plugins/wordtube/player.swf' height='300' width='300' allowscriptaccess='always' allowfullscreen='true' flashvars='volume=80&bufferlength=5&displayclick=none&controlbar=none&linktarget=_self&autostart=true&title=leeds-0036.jpg&file=http%3A%2F%2Fwww.gotyou.co.uk%2Fwp-content%2Fgallery%2FNurses%2FAbb_0056.JPG&plugins=viral'/></textarea>
		</td>
	</tr>		
</tbody>
</table>

 

What should happen is when you click an image, it copies the code from the textarea to the users clipboard so they can paste it where every they want it. Is this possible? How do you do it?

 

I haven't got very far. So far I have gathered the textarea id.

 

function copyit() {
var element = document.getElementById('copy'));
}

Link to comment
Share on other sites

If you want this work reliably crossbrowser you're out of luck, javascript should not be allowed access to the clipboard for obvious reasons (people copying banknumbers, passwords and what not).

However, Internet explorer seems to it though, explained over here: http://www.htmlgoodies.com/beyond/javascript/article.php/3458851

 

If you simply want to store data for a moment I suggest making use of a variable instead.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.