Forum Moderators: open
Anyone here know of one that has better cross-browser results?
How so? Do you mean with a right click option? I know that this isn't very important because it is easily accomplished by right click options, but in a particular application that I'm working on, it would be nice to have a button that could be clicked to "copy highlighted text to clipboard".
BTW, I found your script in a nearby post for copying the contents of an element (a div) onto the clipboard, and I'm playing around with that one (although it's apparently just for IE). Thanks.
Thanks, that's what I thought you meant. What I'm looking for is a javascript to do that at the click of a button, rather than as a right click option. Your script for IE worked well when I adapted it to work with a form button, and I may end up using it. Here's what I did with it:
function sendToClipboard(s)
{
if( window.clipboardData && clipboardData.setData )
{
clipboardData.setData("Text", s);
}
else
{
alert("Internet Explorer required");
}
}
<body>
<input type="button" value="Copy to Clipboard" onclick="sendToClipboard(document.getElementById('textareaIDgoes here').innerHTML)" />
</body>
Anyone?