gpt4 book ai didi

c# - 在 asp.net 中使用零剪贴板将文本复制到剪贴板

转载 作者:行者123 更新时间:2023-12-03 14:28:54 28 4
gpt4 key购买 nike

我正在尝试使用 *剪贴板*从复制文本文本框 剪贴板 当客户点击 按钮 .我已经尝试了很多天,但没有运气使这项工作成功。

在场景中,我有一个 文本框 呈现来自 的数据数据库 .我有一个 按钮 当客户端点击时,应该复制 的文本文本框 .我试过跟随,但它不工作。

一些帮助将不胜感激。

 <script type="text/javascript" src="/Scripts/ZeroClipboard.js"></script>
<script type="text/javascript">
ZeroClipboard.setMoviePath('/Scripts/ZeroClipboard.swf');
</script>



<script>
function test() {

ZeroClipboard.setMoviePath('/Scripts/ZeroClipboard.swf');
//create client
var clip = new ZeroClipboard.Client();

//event
clip.addEventListener('mousedown', function () {
clip.setText(document.getElementById('TextBox2').value);

});
clip.addEventListener('complete', function (client, text) {
alert('copied: ' + text);

});
//glue it to the button
clip.glue('d_clip_button');

}
</script>

<asp:TextBox ID="TextBox2" runat="server" BorderStyle="None" Enabled="False" Font-Size="Medium" ForeColor="Black" Width="213px"></asp:TextBox>
&nbsp;<asp:Button ID="d_clip_button" runat="server" Text="Copy" OnClientClick="javascript:test();" />

最佳答案

<html>
<body>
<button id="copy-button" data-clipboard-text="Copy Me!" title="Click to copy me.">
Copy to Clipboard</button>
<script src="ZeroClipboard.js"></script>
<script src="main.js"></script>
</body>
</html>

//In Main.js file
// main.js
var clip = new ZeroClipboard( document.getElementById("copy-button"), {
moviePath: "/path/to/ZeroClipboard.swf"
} );

clip.on( 'load', function(client) {
// alert( "movie is loaded" );
} );

clip.on( 'complete', function(client, args) {
this.style.display = 'none'; // "this" is the element that was clicked
alert("Copied text to clipboard: " + args.text );
} );

clip.on( 'mouseover', function(client) {
// alert("mouse over");
} );

clip.on( 'mouseout', function(client) {
// alert("mouse out");
} );

clip.on( 'mousedown', function(client) {

// alert("mouse down");
} );

clip.on( 'mouseup', function(client) {
// alert("mouse up");
} );

关于c# - 在 asp.net 中使用零剪贴板将文本复制到剪贴板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17417606/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com