经测试代码如下:
/**
* 兼容各大浏览器的复制代码(结合ZeroClipboard.js)
*
* @param
* @arrange (512.笔记) jb51.cc
**/
<script type="text/javascript" src="ZeroClipboard.js"></script>
<script language="JavaScript">
var clip = null;
function $(id) { return document.getElementById(id); }
function init() {
clip = new ZeroClipboard.Client();
clip.setHandCursor(true);
clip.addEventListener('mouSEOver',function (client) {
// update the text on mouse over
clip.setText( $('fe_text').value );
});
clip.addEventListener('complete',function (client,text) {
//debugstr("Copied text to clipboard: " + text );
alert("该地址已经复制,你可以使用Ctrl+V 粘贴。");
});
clip.glue('clip_button','clip_container' );
}
</script>
</head>
<body onl oad="init()">
<input id="fe_text" cols=50 rows=5 value=复制内容文本1 >
<span id="clip_container"><span id="clip_button"><b>复制</b></span></span>
// 来自:编程之家 jb51.cc(jb51.cc)
原文链接:https://www.f2er.com/js/527718.html