zeroclipboard

如何使用JavaScript复制到剪贴板?

早过忘川 提交于 2019-12-06 06:48:31
将文本复制到剪贴板的最佳方法是什么? (多浏览器) 我试过了: function copyToClipboard(text) { if (window.clipboardData) { // Internet Explorer window.clipboardData.setData("Text", text); } else { unsafeWindow.netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); const clipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper); clipboardHelper.copyString(text); } } 但是在Internet Explorer中,它会给出语法错误。 在Firefox中,它说 unsafeWindow is not defined 。 一个没有闪光灯的好技巧: Trello如何访问用户的剪贴板? #1楼 我发现以下解决方案: 在按下按键时,处理程序会创建“ pre”标签。 我们将内容设置为复制到此标签

zeroclipboard fire click event via jquery

只谈情不闲聊 提交于 2019-12-06 01:22:35
ZeroClipboard is a javascript + flash script that allows the browser to put text into the clipboard, it puts a transparent flash over the selected element , and when you click it you can insert text into the clipboard, this works, no problem, but i want to make it automatic. Onload put a string in the clipboard, for the user to be able to paste it latter. Some code main.js $('document').ready(function() { ZeroClipboard.setMoviePath("http://url/to/ZeroClipboard.swf"); var clip=new ZeroClipboard.Client(); clip.on( 'load', function(client) { clip.glue('#redirlink'); } ); }); html <!DOCTYPE html

ZeroClipBoard的诡异事件

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 00:16:58
最近在帮同事解决跨浏览器访问剪贴板的问题时用到了ZeroClipBoard,这是一个利用flash控件来访问剪贴的组件,在测试页面,是可以正常工作的,复制粘贴很顺畅. 但是在我们的项目应用时却发现了该控件的flash并不能返回complete事件并触发复制的操作. 查阅了很多资料,代码中也无阻止事件冒泡的记录.却始终找不到问题的症结,真是蛋疼到爆啊.在看到了网上对该控件的介绍后,知道该控件是在代码中新增了一个flash,并定位在点击按钮的上方来实现的.然后,在调试工具中看到了flash的dom,高宽都是0,这注定了是无法点击到的.在找到问题的根源之后,对自己的代码进行相应的调整. 来源: oschina 链接: https://my.oschina.net/u/268969/blog/107947

copy text to clipboard with jquery or javascript

江枫思渺然 提交于 2019-12-05 21:03:08
how to copy some text to the clipboard with jquery or javascript, from google. i know there is a pludgin named zeroclipboard http://code.google.com/p/zeroclipboard/ can do this with cross browers. the instructions link http://code.google.com/p/zeroclipboard/wiki/Instructions but when i tested it on my site. i set it to copy text optionally . it can't work. my test link is http://xanlz.com/copy/1.html it always copys all the values. even i uncheck some check box. may be the value doesn't be changed. but when i alter() the variable, the value is ok. how to correct it? thank you. i want it can

zClip - ZeroClipboard.swf deleted - Need new file

五迷三道 提交于 2019-12-05 07:44:46
I'm using zClip on my website to copy several things in textboxes, I got everything working just fine but now, without changing anything, it stopped working. The reason is that the host of the file ZeroClipboard.swf have deleted the file or for some reason made inaccessible. I have an other version(?) of the ZeroClipboard.swf on my computer from another script and I tried replacing the deleted link with a new link of the other version(?) I found on my computer. But it doesn't work, the flash movie loads but I can't click my button and copy the content. When I'm using the old link that doesn't

Zeroclipboard multiple elements

半腔热情 提交于 2019-12-04 13:08:26
I'm having trouble creating multiple Zeroclipboard instantiations in my code, with each instantiation launching a popup window after it is invoked. <a class="xxx" href="popup.url.php" ><span >FRSDE3RD</a> <a class="xxx" href="popup.url2.php" ><span >FRSDE3RD2</a> <a class="xxx" href="popup.url3.php" ><span >FRSDE3RD3</a> $(document).ready(function(){ ZeroClipboard.setMoviePath( 'path/to/swf/ZeroClipboard.swf' ); // setup single ZeroClipboard object for all our elements clip = new ZeroClipboard.Client(); clip.setHandCursor( true ); // assign a common mouseover function for all elements using

JQuery zClip兼容所有浏览器的插件 实现复制到剪贴板功能

青春壹個敷衍的年華 提交于 2019-12-04 09:48:54
1,引用jQuery 以及 jquery.zclip.min.js <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://cdn.bootcss.com/zclip/1.1.2/jquery.zclip.min.js"></script> 2,html格式 <input type="text" value="www.sitejs.cn" id="link"> <span id="copyBtn">复制链接</span> 3,js调用 $('#copyBtn').zclip({ path: "ZeroClipboard.swf", copy: function(){ return $('#link').val();       }, afterCopy:function(){ alert('复制成功'); } }); 来源: oschina 链接: https://my.oschina.net/u/2393989/blog/3026344

How to copy using clipboard.js with dynamic content and triggers

ぐ巨炮叔叔 提交于 2019-12-04 03:43:02
问题 After a click on .fw-code-copy-button I would like to copy source code from it's nearest container. .fw-code-copy-button -s are created dynamically, after user click dedicated "view source" button. Html for example button: <span class="fw-code-copy"> <span class="fw-code-copy-button" data-clipboard-text="...">copy</span> </span> This is how i trigger click event, and define the source code to be copied to clipboard: $(document).on("click", ".fw-code-copy-button", function(){ var source = $

Clipboard.js : 移动端浏览器实现网页内容复制

半腔热情 提交于 2019-12-03 20:06:43
最近在项目中遇到这样一个需求: 点击按钮,将指定的URL复制到剪贴板,然后用户可以粘贴到浏览器(Safari为主)自行打开。 方案一:zeroClipboard.js github地址 :https://github.com/zeroclipboard/zeroclipboard 复制原理 :zeroClipboard利用透明的 flash 覆盖在复制按钮上,点击 flash,将复制内容传入到 flash 中,再通过 flash 把传入的内容写到剪贴板上 首先想到这个插件的原因是,之前在PC端的项目中使用过,兼容性很好,驾轻就熟,所以,先用它做了个demo HTML ? 1 2 < input type="text" name="" id="iUrl" value="https://github.com/zeroclipboard/zeroclipboard"> < button id="copyUrlBtn">复制链接</ button > JAVASCRIPT ? 1 2 3 4 5 6 7 8 9 10 11 ( function (){ var btn = document.getElementById( 'copyUrlBtn' ), text = document.getElementById( 'iUrl' ), zc = new ZeroClipboard(btn)

如何使用JavaScript复制到剪贴板?

扶醉桌前 提交于 2019-12-03 02:05:13
将文本复制到剪贴板的最佳方法是什么? (多浏览器) 我试过了: function copyToClipboard(text) { if (window.clipboardData) { // Internet Explorer window.clipboardData.setData("Text", text); } else { unsafeWindow.netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); const clipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper); clipboardHelper.copyString(text); } } 但是在Internet Explorer中,它会给出语法错误。 在Firefox中,它说 unsafeWindow is not defined 。 一个没有闪光灯的好技巧: Trello如何访问用户的剪贴板? #1楼 我发现以下解决方案: 在按下按键时,处理程序会创建“ pre”标签。 我们将内容设置为复制到此标签