Domanda

I am using zclip plugin for copying text to clipboard. It works fine for plain text.

But when I try to copy some formatted text say for eg:

I am having div with html as

<div id="formattedDiv">
  <b>Copied Text </b>
</div>

and when I apply zclip on some button to copy formmattedDiv text as

$("a#copyCustombtn").on('click', function (e) {
    e.preventDefault();
}).zclip({
    path: 'http://www.steamdev.com/zclip/js/ZeroClipboard.swf',
    copy: function () {
     return $("#formattedDiv").html()
    }
  }); 

It copies entire html as "<b>Copied Text </b>".

When I try to paste, it pastes exactly "<b>Copied Text </b>"

but not formatted text as "Copied Text "

Can anybody guide me, why this happening?

È stato utile?

Soluzione 2

Currently zclip won't provide such a way to implement. Raised an issue on github please refer to link in which suggestion are welcomed.

Hope it will be implemented soon :)

Altri suggerimenti

Zclip will only copy text to your clipboard. If you include HTML characters in that text, it will copy the html characters to your clipboard, not the formatted text.

If you only want the text and not the HTML characters, use:

copy: function () {
  return $("#formattedDiv").text()
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top