I am unable to paste the content to a textbox whose property "Textmode"is multiline this is开发者_JAVA技巧sue is happening in google chrome and safari browsers
For safe side, implement clipboard functionality using ZeroClipboard, works on all browser, irrespective of any browser copy - paste feature.
See its usage below. Download and extract the Zeroclipboard in your project
<script src="zeroclipboard/ZeroClipboard.js" type="text/javascript"></script>
<script type="text/javascript" >
ZeroClipboard.setMoviePath('zeroclipboard/ZeroClipboard.swf');
<script language="JavaScript" type="text/javascript">
var clip = null;
function init() {
clip = new ZeroClipboard.Client();
clip.setHandCursor(true);
clip.addEventListener('load', function(client) {
});
clip.addEventListener('mouseOver', function(client) {
// update the text on mouse over
clip.setText(document.getElementById('TextBox1').value);
});
clip.addEventListener('complete', function(client, text) {
Label1.innerText = document.getElementById('TextBox1').value + ' Copied to clipboard.';
});
clip.glue('divbutton', 'divcontainer');
}
</script>
1. Don't forget to set <body onLoad="init()">
2. Set the clip.SetText method in onchnage event of the textbox. <td align="left">
<asp:TextBox ID="TextBox1" runat="server" Width="218px" onchange="clip.setText(this.value)"></asp:TextBox>
</td>
3. <div id="divcontainer" style="position: relative; top: 0px; left: 0px; width: 193px;">
<div id="divbutton" class="mybutton">
<b>Copy To Clipboard...</b></div>
</div> in case use need to some button's illusion on page.
精彩评论