Javascript Copy All

This is a discussion on "Javascript Copy All" within the JavaScript Forum section. This forum, and the thread "Javascript Copy All are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Aug 28th, 2007, 14:12
New Member
Join Date: Aug 2007
Location: San Antonio, TX
Age: 21
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Javascript Copy All

I was wondering if there is a way to have a link or button on my page that would copy everything on that page just by clicking it.

Thanks for any help!
Reply With Quote

  #2 (permalink)  
Old Aug 28th, 2007, 14:19
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: Javascript Copy All

hmm modifying this might help:
http://www.codeave.com/javascript/code.asp?u_log=7004
it's better to just highlight it, people don't like to lose stuff in their clipboard
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #3 (permalink)  
Old Aug 28th, 2007, 14:25
New Member
Join Date: Aug 2007
Location: San Antonio, TX
Age: 21
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Javascript Copy All

I've tried modifying this script, but couldn't find out how to make it select a div, or something outside of the forum.

If at all possible, I would have liked it to select everything in the body of the page. Any Suggestions?
Reply With Quote
  #4 (permalink)  
Old Sep 4th, 2007, 14:46
Up'n'Coming Member
Join Date: Aug 2007
Location: Bicester
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Javascript Copy All

Can you not step through all the elements and get the content?

This just gets all the text in spans but you could do the same with divs and other elements.

Code: Select all
 
<script>
var spans = document.getElementsByTagName("span");
var str = '';
for (i=0;i < spans.length;i++) 
{
str+= spans[i].childNodes[0].data;
}
alert(str);
 
window.clipboardData.setData("Text",str); //Ie only
</script>
Justin

Last edited by Kropotkin; Sep 4th, 2007 at 14:49. Reason: improvement
Reply With Quote
  #5 (permalink)  
Old Sep 7th, 2007, 08:01
New Member
Join Date: Apr 2007
Location: india
Age: 28
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Javascript Copy All

Hi,

i had used the javascript to select the content of the div tag. i used the code from the below url

http://hscripts.com/scripts/JavaScri...ct-div-tag.php

Change it accordingly for your need

Gemguy
Reply With Quote
Reply

Tags
copy, javascript, text

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need DVD copy software! tristan Webforumz Cafe 11 Feb 18th, 2008 20:41
Javascript Copy to clipboard Object Error andrewlondon JavaScript Forum 1 Sep 24th, 2007 13:15
File copy Thanuja Other Programming Languages 0 Jun 25th, 2007 07:12
Copy writing nate2099 Starting Out 7 Jun 19th, 2007 22:13
Cant Copy and Paste smudger1767 Web Page Design 11 Mar 24th, 2006 15:06


All times are GMT. The time now is 00:02.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43