JS/FLASH实现复制代码到剪贴板(兼容所有浏览器)(2)


a.htm
<html>
<head>
<title>Zero Clipboard Test</title>
<style type="text/css">
body { font-family:arial,sans-serif; font-size:9pt; }
.my_clip_button { width:150px; text-align:center; border:1px solid black; background-color:#ccc; margin:10px; padding:10px; cursor:default; font-size:9pt; }
.my_clip_button.hover { background-color:#eee; }
.my_clip_button.active { background-color:#aaa; }
</style>
</head>
<body>
<div>
<div><b>Copy To Clipboard...</b></div>
</div>
<textarea onChange="clip.setText(this.value)">我复制</textarea>
<script type="text/javascript" src="https://www.jb51.net/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('load', function (client) {
debugstr("Flash movie loaded and ready.");
});
clip.addEventListener('mouseOver', function (client) {
// update the text on mouse over
clip.setText( $('myresource').value );
});
clip.addEventListener('complete', function (client, text) {
debugstr("Copied text to clipboard: " + text );
});
clip.glue( 'd_clip_button', 'd_clip_container' );
}
setTimeout(function(){
init();
},1500);
</script>
</body>
</html>


flash文件请自己到网上下载哈~

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wdgdsp.html