<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,
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