Welcome to WebmasterWorld Guest from 54.158.36.59

Forum Moderators: open

Message Too Old, No Replies

Copying content(Not from textarea)

Copy content from a paragraph when click on a button

     
5:14 am on Mar 9, 2012 (gmt 0)



Copying content from a div when clicking a button
6:19 am on Mar 9, 2012 (gmt 0)

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Hello ocsbala, and welcome to the forums.

I'm not clear about your question. Do mean how to write the script for a button that places div content onto the clipboard?

[edited by: tedster at 7:59 am (utc) on Mar 9, 2012]

7:37 am on Mar 9, 2012 (gmt 0)



Hi tedster, Below are my code. It is working fine with IE, but Firefox showing error .

window.clipboardData is undefined


<script type="text/javascript" language="javascript">
function copyText()
{
var copyDivText = document. getElementById( 'content' ) .innerText;
var returnVal = window. clipboardData. setData( 'Text', copyDivText );
}
</script>
<div id="content">
Lorem Ipsum is simply dummy text.
</div>
<input type="button" id="btn" value="copy" onclick="copyText()">

Can you please provide solution for my problem.
7:58 am on Mar 9, 2012 (gmt 0)

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I don't really know a lot about this area - but I did want to help you clarify your question so maybe others can help. Doing a little research, I found that others have had the same question around the web, but the answers I found weren't very clear.

Does this approach help you? See Zero Clipboard [code.google.com] from Google Code
 

Featured Threads

Hot Threads This Week

Hot Threads This Month