• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

javascript problem

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I have a requirement which is to copy the contents of a screen (contents are all labels but these labels are dynamically generated) using a button on that screen.i.e the button should do the work of ctrl+Aand ctrl+C (select all , copy). Can any one guide me as to how to do it.


Comments really appreciated.

Thanks
Siddharth
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
siddharth,

There is an HTML/Javascript forum on this site:
https://coderanch.com/forums/f-20/HTML-JavaScript
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moved to the HTML/Javascript forum.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://www.krikkit.net/howto_javascript_copy_clipboard.html

You can probably use tht script and do this to get the text..

<input type="button" name="b1" value="copy" onclick="copy_clip(document.body.innerHTML)">

to lazy to test, might work, never know...

Eric
 
siddharth sharma
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got the soln..
pust the text in a span and
then use this function

function getSelected1()
{
var text1 = document.getElementById('span1').innerHTML
window.clipboardData.setData('Text', document.getElementById('span1').innerHTML)
document.getElementById('span1').style.color= 'white'
document.getElementById('span1').style.background= 'black'
}


span id="span1"
Hi there!!!
/span
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic