How to copy html output to clipboard to use in gmail signature

Viewed 337

My code below copy the html tag but i want copy the output bold wow to paste in on gmail signature

function wow(){
const el = document.createElement('textarea');
  el.value ="<h1>wow<h1>";
  document.body.appendChild(el);
  el.select();
  document.execCommand('copy');
  document.body.removeChild(el)
}
<button onclick="wow()">
Copy to clipboard
</button>

1 Answers

You should try and manipulate it:

  document.getElementById('markup-copy').addEventListener('click', function() {
            clipboard.copy({
                'text/plain': 'Markup text. Paste me into a rich text editor.',
                'text/html': '<i>here</i> is some <b>rich text</b>'
            }).then(
                function() {
                    console.log('success');
                },
                function(err) {
                    console.log('failure', err);
                });

        });
<button id='markup-copy'>Copy to the clipboard</button>

Also, check out this link: clipboard-polyfill

Related