复制到剪贴板,无需单击 [英] copy to clipboard without click

查看:124
本文介绍了复制到剪贴板,无需单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此插件复制到剪贴板。



https:/ /github.com/zeroclipboard/ZeroClipboard [ ^ ]



但是我希望它不用点击按钮就可以了。



我想要它在页面上做加载,它会自动将文本从url param复制到剪贴板。



有办法吗?



这是我的代码但没有工作:



I am using this plugin for copy to clipboard.

https://github.com/zeroclipboard/ZeroClipboard[^]

But I want it to do without clicking on a button.

I want it to do when the page load, it automatically copy the text from the url param to clipboard.

Is there a way to do it?

Here's my code but not working:

<script type="text/javascript" src="/js/ZeroClipboard.js"></script>
	<script type="text/javascript">
	$(document).ready(function () {
		var key = GetURLParameter('key');
		//alert(key);
		
		var clip = new ZeroClipboard( window.onload, {
			moviePath: "/js/ZeroClipboard.swf"
		} );
		
		clip.on( 'load', function(client) {
			copy: key
		} );
	});
	
	function GetURLParameter(sParam)
	{
		var sPageURL = window.location.search.substring(1);
		var sURLVariables = sPageURL.split('&');
		for (var i = 0; i < sURLVariables.length; i++) 
		{
			var sParameterName = sURLVariables[i].split('=');
			if (sParameterName[0] == sParam) 
			{
				return sParameterName[1];
			}
		}
	}
	</script>

推荐答案

(文件).ready(function(){
var key = GetURLParameter('key');
// alert(key);

var clip = new ZeroClipboard(window.onload ,{
moviePath:/ js / ZipClipboard.swf
});

clip.on('load',function(client){
copy: key
});
});

函数GetURLParameter(sParam)
{
var sPageURL = window.location.search.substring(1);
var sURLVariables = sPageURL.split('&');
for(var i = 0; i< sURLVariables.length; i ++)
{
var sParameterName = sURLVariables [i] .split('=');
if(sParameterName [0] == sParam)
{
return sParameterName [1];
}
}
}
< / script>
(document).ready(function () { var key = GetURLParameter('key'); //alert(key); var clip = new ZeroClipboard( window.onload, { moviePath: "/js/ZeroClipboard.swf" } ); clip.on( 'load', function(client) { copy: key } ); }); function GetURLParameter(sParam) { var sPageURL = window.location.search.substring(1); var sURLVariables = sPageURL.split('&'); for (var i = 0; i < sURLVariables.length; i++) { var sParameterName = sURLVariables[i].split('='); if (sParameterName[0] == sParam) { return sParameterName[1]; } } } </script>


1.add listener toctrl + c

2.来自剪贴板的内容

3.设置你要去的地方的内容



1.add listener to "ctrl+c"
2.get content from clipboard
3.set the content there where you want to palce

var ctrl = false;


function (){


这篇关于复制到剪贴板,无需单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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