跨浏览器的复制粘贴方案
代码和博客都是用了原作者的,具体请参见作者的原文:
http://www.rahulsingla.com/blog/2010/03/cross-browser-approach-to-copy-content-to-clipboard-with-javascript
http://www.rahulsingla.com/blog/2010/03/extjs-copy-gridpanel-content-to-clipboard
http://www.rahulsingla.com/blog/2010/10/extjs-copying-gridpanel-single-row-data-to-clipboard
方案就是IE下直接用javascript的window.clipboardData.setData
其他浏览器用flash+javascript实现
第1个例子:实现功能:复制文本框内的字符到剪切板
1clipboard.htm
嵌入一个flash,
{dataIndex: 'company',width: 30,xtype: "templatecolumn",tpl: new Ext.XTemplate("<object id='clipboard{[this.getClipboardId(values)]}' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' width='16' height='16' align='middle'>","<param name='allowScriptAccess' value='always' />","<param name='allowFullScreen' value='false' />","<param name='movie' value='clipboard.swf' />","<param name='quality' value='high' />","<param name='bgcolor' value='#ffffff' />","<param name='flashvars' value='callback=f1&callbackArg={[this.getClipboardId(values)]}' />","<embed src='clipboard.swf' flashvars='callback=f1&callbackArg={[this.getClipboardId(values)]}' quality='high' bgcolor='#ffffff' width='16' height='16' name='clipboard{[this.getClipboardId(values)]}' align='middle' allowscriptaccess='always' allowfullscreen='false' type='application/x-shockwave-flash' pluginspage='http://www.adobe.com/go/getflashplayer' />","</object>",{getClipboardId: getClipboardId})}