当我单击时如何自动选择和复制 [英] how to select and copy automatically when i click

查看:93
本文介绍了当我单击时如何自动选择和复制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hai,
当我在文本框中单击时如何自动选择和复制???

在此先感谢...

hai,
how to select and copy automatically when i click in the text box???

thanks in advance...

推荐答案

在您的文本框中使用... onFocus ="javascript:this.select()
例如.
in ur textbox use ... onFocus="javascript:this.select()
eg.
<asp:textbox id="txt1" runat="server" text="Abc" onfocus="javascript:this.select();" >



这样,您可以选择ur文本框的文本

一个onClick="Copy(this.id)"



With this u can select the text of ur textbox

An onClick="Copy(this.id)"

function Copy(IDS) {
  document.getElementById("ur id ").value=document.getElementById(IDS).innerHTML;
}


看看将Javascript复制到剪贴板 [ [
Have a look at Click... It''s Copied![^]. Nice way to copy text.

Javascript Copy To Clipboard[^] might help you as well.
This[^] is another link that provides a similar solution.


当用户不希望将数据复制到剪贴板时,这是非常糟糕的.想象一下,您从文本文档和网站向剪贴板中添加了一些文本.现在,您想将此文本添加到文本框中,但是当您单击文本框并粘贴时,您会发现原来的剪贴板文本没有出现,因为它已被文本框中的上一个文本替换.但是您没想到.您甚至可能关闭了原始文本文档或网页.

从这个例子中,您了解您将对用户实施哪种犯罪吗?如果是这样,请不要这样做.

—SA
It''s very bad to copy data to the clipboard when a user does not expect it. Imagine, you put some text to the clipboard from a text document and a Web site. Now, you want to add this text to your text box, but when you click on your text box and paste, you will find out that you old clipboard text did not appear, because it was replaced by the previous text from your text box. But you did not expect it. You maybe even closed original text document or a Web page.

From this example, do you understand what kind of crime you are going to commit against your user? If so, don''t do it.

—SA


这篇关于当我单击时如何自动选择和复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆