Copy to Clipboard using JavaScript.

Vishalneeraj-24503
Posted by Vishalneeraj-24503 under JavaScript category on | Points: 40 | Views : 1084
Sometime we may have scenario like copy small or huge data from application to other places,so in this situation JavaScript - window.clipboardData.setData used to copy the required details from div or other controls in the application see the below JavaScript function.

<script language = "javascript" type = "text/javascript">
function Copy_To_Clipboard(clipdata)
{
if (window.clipboardData)
{
window.clipboardData.setData('text',clipdata);
}
}
</script>

<a href = "#" id = "copytext" onclick = "javascript:Copy_To_Clipboard(document.getElementById('text').innerHTML);">
Click here copy to clipboard</a>

<asp:TextBox ID = "TextBox1" TextMode = "MultiLine" runat = "server" Height = "88px" Width = "312px">Paste
here.</asp:TextBox>

Note: Above code works only IE browser.

Comments or Responses

Login to post response