//<script src="js/ZeroClipboard.js" type="text/javascript"></script> //ZeroClipboard.js //ZeroClipboard.swf //用ZeroClipboard容器,实现页面表格数据copy //--用字符串拼html function copyTable(data,mode,outtype){ var html=[]; html.push("<html>"); html.push("<head>"); html.push("<style>"); html.push("td{border:1px solid #A3C0E8;overflow:hidden;white-space:nowrap;}"); html.push(".htd{background-color:#00619C;color:#FFFFFF}"); html.push(".std{font-weight: bold;}"); html.push(".gtd{background-color:#DDDDDD;}"); html.push("</style></head><body><table>"); html.push("<tr>"); html.push("</tr>"); html.push("</table></body></head></html>"); return html.join(""); } //容器的大小是有限的,一般到100万个字左右,超过容器空间大小,copy失效 function init(mode,outtype) { ZeroClipboard.setMoviePath("js/ZeroClipboard.swf"); clip = new ZeroClipboard.Client(); clip.setHandCursor(true); var result=""; clip.addEventListener('mousedown', function(client) { //拼table返回的html文 result = copyTable(copyDatatmp,mode,outtype); clip.setText(result); }); clip.addEventListener('complete', function(client, text) { if (result.length>800000) { alert("数据容量太大,copy失效。"); }else { clip.reposition(); alert("copy完了!"); } }); clip.glue("copymt"); $(window).resize(function() { clip.reposition(); }); }