Copy content from a paragraph when click on a button
ocsbala
5:14 am on Mar 9, 2012 (gmt 0)
Copying content from a div when clicking a button
tedster
6:19 am on Mar 9, 2012 (gmt 0)
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]
ocsbala
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.
tedster
7:58 am on Mar 9, 2012 (gmt 0)
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