0

Possible Duplicate:
How to copy to the clipboard in JavaScript?

Suppose I have a webpage with this content:

<h1 id="foo"> Some string </h1>

Now I want to to copy Some string to clipboard. But the conditions are:

  • My webpage (app) is mouse oriented so I don't want to let the users to touch the keyboard.
  • Right click is already engaged in another task, so I can't use right.

The only way is to hover over the <h1> with id="foo" and press left mouse button.

I googled it and found a JavaScript way to do this. But soon I knew that that's not cross browser. So, is there is way to copy text on left click of the hovered h1.

Community
  • 1
  • 1
Santosh Kumar
  • 26,475
  • 20
  • 67
  • 118

2 Answers2

1

Using an adobe flash call is probably your best bet.

I have used this one with marginal success: http://code.google.com/p/zeroclipboard/

If the java method is not acceptable because it is not cross browser compatible I am not even going to suggest some decrepit (and probably security hole causing) Active X component which would effectively be IE only (with few exceptions).

Dave
  • 1,823
  • 2
  • 16
  • 26
0

Started the search here and found http://www.steamdev.com/zclip


This plugin is cross-compatible with all browsers and works well: http://plugins.jquery.com/project/clipboard

Nildarar
  • 802
  • 1
  • 8
  • 17