我想允许用户复制大量的电子邮件地址到他们的剪贴板。这个答案似乎是最可靠的方法:
如何用JavaScript复制到剪贴板?
然而,在测试时,我发现窗口。prompt()
始终将其中一封电子邮件的一部分替换为
。
下面是测试数据:
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com; test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;
下面是具有以下测试数据的示例代码:
window.prompt ("To copy emails to clipboard, press: Ctrl+C, then Enter",
"test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com; test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;test@test.com;test@test.com;test@test.com;
test@test.com;test@test.com;");
JSFiddle:http://jsfiddle.net/MkYDz/
点击上面的链接,复制并粘贴文本到文本编辑器,你会看到其中一封电子邮件(大约一半)变成:
test@...om
为什么会发生这种情况?
如果我有更多的声誉点,我会评论Jitesh的回答...
如果你不使用jQuery,你不能这样做:
emailsTxtArea.select().focus();
相反,您必须这样做:
emailsTxtArea.select();
emailsTxtArea.focus();
在常规javascript中,select方法不返回对象。
window.prompt()函数在Chromium中限制为2000个字符。如果输入字符串超过此限制(您的示例有2059个字符),则将在标有点的中间剪切输入字符串。这被称为省略号。
这里有一个正好使用2000个字符的演示(我用XXX替换了最后三个字符):http://jsfiddle.net/MkYDz/2/
;test@tesXXX");
提示的字符限制似乎是MVP所说的原因。有一个相当好的变通方法。使用一个以电子邮件文本为内容的文本区域,并使用选择函数在文本区域中选择整个文本,就像您在提示符中所做的那样。
例子:
$('#container').append('To copy emails to clipboard, press: Ctrl+C, then Enter <br />
<textarea id="emailsToCopy">'+emailsToCopy+'</textarea>');
$('#emailsToCopy').select().focus();
假设您使用jQuery。如果没有,您可以在文本区域DOM元素上使用选择函数。
var emailsTxtArea = document.getElementById(emailsToCopy);
emailsTxtArea.select();
emailsTxtArea.focus();
引用脚本的内容: ; 该脚本使用 HM VNISEdit 脚本编辑器向导产生 ; 安装程序初始定义常量 !define PRODUCT_NAME "飞扬组件选择工具" !define PRODUCT_VERSION "1.0.0.0" !define PRODUCT_PUBLISHER "霸王硬上弓" !define PRODUCT_WEB_SITE "http://www.SooWind.c
我试图开发一个由多个数组和文本视图组成的应用程序,我遇到了一个问题。 我有3个文本视图和2个数组。 我的一个数组包含句子。我的第一个问题是如何突出每个句子中的特定单词?例如:“这是我的第一个数组项”,我需要突出显示字符串中的一个单词,这样当它显示在文本视图1中时,它就会像这样出现..."这是我的第一个数组物品" 我的另一个数组包含单词。它们显示在textview2中,也应高亮显示。我的下一个问题是
我正在IE上测试。单击后,我切换到子窗口,但无法返回父窗口,出现错误“窗口已关闭”。
长话短说,我搜索了与我类似的问题,所以我可以“自己”解决这个问题。我在这里和这里找到了这些例子,但没有一个对我有用。 我需要将在第一个窗口的TextField中键入的字符串传递给下一个窗口。 我的主要: 当我使用FXML时,这是Window1(java1)的控制器: 以及Window2的控制器(java2): 问题指向我用自定义函数(j2.setLbText)设置Text的Java1Control
我的问题是我传递给新创建的窗口的NOT NULL参数为NULL。我读过很多关于如何通过setter将参数传递到另一个窗口的帖子,对我来说似乎一切都很好,但它并不起作用。 正如调试器所说,以及似乎为空。错误消息:
我有一个带有“搜索栏”(EditText)和列表视图的RelativeLayout: 在用户“搜索”之后,我希望 EditText 以动画形式离开屏幕,并将 ListView 推送到顶部。我整理了一个非常粗糙的GIF,我需要什么: 有人知道我如何做到这一点吗?谢谢 更新 我发现了如何使EditText动画从屏幕上显示: slide_out_top.xml 然后在EditText上使用它,如下所示: