Monday 15 August 2011

javascript - Copy as html to clipboard programmatically -


C . The problem is that all the plugins I tried (zClip, ZeroClipboard) just copy the plain text and then if I paste it into Microsoft Word then just paste the text, but the HTML is not what it shows. Is there any way to do that? I tried to find out my problem here and on the other parts but I can not.

  window.zclip_copyTaskReference = event (event) {debugger; Try {var self = $ (event.target); Var taskId = self.attr ('data-work-id'); Var workName = self.attr ('data-work-name'); Var href = location.href.replace (/ [#] $ /, ''); Var link = $ ('& lt; a & gt; & lt; / a & gt;'); Link.attr ('href', href); Link.text (taskName); Var html = link.wrap ($ ('& lt; div / & gt;')). mother-father (). Html (); Success message ('Link copied to clipboard'); // Return link [0]; Return html.trim (); // return (html); } Hold (e) {error message ('failed to copy link'); Return ''; }};   

init:

  $ ('.copy-link'). Zclip ({path: '/Scripts/jquery/zclip/Zeroclipboard.swf', copy: window.zclip_copyTaskReference, afterCopy: $ .noop ()});    

code & lt; Pre & gt; tag or & lt; Code & gt; If it is not working, you can capture the contents of the content by jquery method, serialize it into a string, and copy it to the clipboard.

No comments:

Post a Comment