0

I want to know if it is possible to select the text anywhere on a webpage and then copy it using jQuery or Javascript.In another language how to invoke CTRL+X,CTRL+C and CTRL+V on a selected text using jQuery or Javascript?.Can this be done?However the CUT command will be invoked on the text which is present in a textarea or textbox not on the hypertext of the webpage. Please let me know.

animuson
  • 50,765
  • 27
  • 132
  • 142
techie_28
  • 2,025
  • 4
  • 37
  • 56
  • Some methods of copying text in browsers to clipboard are [listed here](http://stackoverflow.com/questions/400212/how-to-copy-to-clipboard-in-javascript). You can adapt them to your need. – approxiblue Feb 24 '12 at 05:16
  • I dont want to use flash Jimmy. – techie_28 Feb 24 '12 at 05:28

2 Answers2

2

You could probably invoke the buttons, and copying text on a webpage is most certainly possible with access to the DOM, however it seems like what you are trying to do is access the clipboard, and the way to do that consistently is usually with flash.

The ZeroClipboard plugin is the one most commonly used, it's easy to integrate and gives you full access ro the clipboard.

For an example have a look at CSS3Please, I believe they are using the ZeroClipboard plugin.

adeneo
  • 293,187
  • 26
  • 361
  • 361
  • Then your limited to some pseudo code that only works in IE, no other browser that I know of will allow access to the clipboard from javascript. – adeneo Feb 24 '12 at 05:47
2

Can this be done? ... I don't want to use Flash

No, not if you need it to work in all major browsers.

Madbreaks
  • 17,159
  • 7
  • 50
  • 64