This will copy the text in a given field to the clipboard. Unfortunately it only works in IE, so Firefox users will still need to do the actual copy. But it'll at least select the text for Firefox users.
Here is how you set up your HTML:
<form name=myform>
<input type=text name=mytext value='This text will be copied'>
<input onclick="javascript:copyToClipboard('myform.mytext')" type="button" value="Send to Clipboard">
</form>
You can name the form and text box anything you'd like. Just be sure to send the proper parameters to the copyToClipboard function. You may also use a textarea like we do here for our snippets.
function copyToClipboard(field)
{
var content = eval("document."+field)
content.focus()
content.select()
range = content.createTextRange()
range.execCommand("Copy")
window.status="Contents copied to clipboard"
setTimeout("window.status=''",1800)
}
@vigneswaranj This is very old. I'd search Google for something more up to date. I know in the past we had to use something like ZeroClipboard which is a flash solution, but there may be something better now.
Copy to Clipboard Javascript ..how i will run in crome...pls give for crome