页面点击复制 兼容 firefox ie chrome(使用js+flash)cross-browers-copy

<script type="text/javascript" src="@Url.Content("~/Scripts/cross-browers-copy/ZeroClipboard.js")"></script>
ZeroClipboard.setMoviePath('@Url.Content("~/scripts/cross-browers-copy/ZeroClipboard.swf")'); 
var clip = new ZeroClipboard.Client();
clip.setText('');
clip.setHandCursor(true);
// 监听复制完毕事件
clip.addEventListener('complete', function (client, text) {
  //复制完成出现的提示使用alert后,在firefox出现遮罩的错误,无法点击任何地方,最小化再最大化后显示出alert,因此换用jquery ui   $("<div>复制成功</div>").dialog({     autoOpen: true,     width: 200,     height: 150,     modal: true,     buttons: {       "确定": function () {         $(this).dialog('close');         mDialogCallback(true);       }     }   }); }); clip.addEventListener('mouseDown', function (client) {   var temp = $("#dimensionTab .visited").attr("data_value");   clip.setText($("div[data_value=" + temp + "]").text()); }); clip.glue("copy_text");
//示例和相关文件下载如下地址。
//https://github.com/sofish/Alice/tree/master/solutions/cross-browers-copy
posted @ 2013-03-12 19:08  逸新  阅读(491)  评论(0编辑  收藏  举报