标签:style blog color io os ar java for sp
<script type="text/javascript" src="../Scripts/jquery-1.8.2.min.js"></script> <script type="text/javascript" src="../js/ZeroClipboard/ZeroClipboard.js"></script> <script type="text/javascript"> $(function () { function setClipboardText(clickBtnId, setTxtFn, completeMsg) { //如果页面文件与js文件不在同一目录下 ZeroClipboard.setMoviePath("../js/ZeroClipboard/ZeroClipboard.swf"); var clip = new ZeroClipboard.Client(); //创建新的Zero Clipboard对象 clip.setText(‘‘);//清空剪贴板 clip.setHandCursor(true); //设置鼠标移到复制控件时的形状 clip.setCSSEffects(true); //启用css //---------------------------------------------------------- clip.addEventListener(‘mouseDown‘, function () {//鼠标按下讲 if (setTxtFn) { setTxtFn(); } }); //--------------------------------------------------------- clip.addEventListener(‘complete‘, function () { //复制完成后的监听事件 if (completeMsg && clip.clipText) { alert(completeMsg);//复制成功弹出的信息 } }); clip.glue(clickBtnId); return clip; } //----------------------------------------------------------------- (function () { var oClip = null;//加载完成才执行 var setTxtFun = function () { $.post("../Handler/CopyHandler.ashx", {}, function (data) { if (data != "" && oClip) { oClip.setText(data);//设置剪贴板内容 } }); } oClip = setClipboardText(‘btnCopy‘, setTxtFun, ‘已成功复制到你的剪贴板‘); })(); }) </script> </head> <body> <form id="form1" runat="server"> <div> <input type="text" id="txt1" value="" /> <input type="button" id="btnCopy" value="Copy" /> </div> </form> </body> </html>
标签:style blog color io os ar java for sp
原文地址:http://www.cnblogs.com/zjflove/p/4052469.html