homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

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)

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 );
<div id="content">
Lorem Ipsum is simply dummy text.
<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)

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

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved