In this section, we will see how to copy the content of the multi-line text box to the clipboard.
Note: jQuery clipboard plugin only supports IE
Interface code:Copy codeThe Code is as follows: <form id = "form1" runat = "server">
<Div align = "center">
<Fieldset style = "width: 400px; height: 300px;">
<P> enter your comment: </p>
<Asp: TextBox ID = "txtComment" TextMode = "MultiLine" Rows = "5" Width = "300px" Height = "200px"
Runat = "server"> </asp: TextBox>
<Br/>
<Asp: HyperLink ID = "lnkHighlight" Text = "click to copy comments" runat = "server"> </asp: HyperLink>
</Fieldset>
</Div>
</Form>
Display interface:
Script:Copy codeThe Code is as follows: <script src = "Scripts/jquery-1.4.1-vsdoc.js" type = "text/javascript"> </script>
<Script src = "Scripts/jquery. clipboard. js" type = "text/javascript"> </script>
<Style type = "text/css">
A
{
Color: # 0000FF;
Cursor: pointer;
}
</Style>
<Script type = "text/javascript">
$ (Document). ready (function (){
$. ClipboardReady (function (){
$ ("A"). click (function (){
$ ("# <% = TxtComment. ClientID %>"). select ();
$. Clipboard ($ ("# <% = txtComment. ClientID %>"). val ());
});
});
});
</Script>
After adding the script, click Copy to display the following results:
Press Ctrl + V to open notepad:
Haha is successful, that's easy.
Plug-in: http://plugins.jquery.com/project/clipboard
In addition, there is a Zero clipboard plug-in that supports cross-browser, it is implemented through a flash file and the JavaScirpt interface, for more information, please visit http://code.google.com/p/zeroclipboard/