I am making a basic email signature page that I want to be able to use a 'Copy to Clipboard' button / command.
I have it working, although instead of pasting a formatted graphic ready for inclusion in outlook or mac mail, it pastes the actual html. e.g.
<table width="100%" cellspacing="0" cellpadding="0" border="0" ...
My code is below and I'd be really grateful for some guidance.
function copyToClipboard(element) {
var $temp = $("<input>");
$("body").append($temp);
$temp.val($(element).html()).select();
document.execCommand("copy");
$temp.remove();
$("#success").slideDown("slow");
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<div id="email-signature" style="border-bottom: 1px solid #000; padding: 10px 0; margin-bottom: 10px;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="padding: 0 0 5px 0; font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 17px; color: #000; font-weight: bold;">
Name of Person
</td>
</tr>
<tr>
<td style="padding: 0 0 5px 0; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 17px; color: #000; ">
<a href="mailto:email@example.com">email@example.com</a>
</td>
</tr>
<tr>
<td style="padding: 0 0 5px 0; ">
<a href="http://www.example.com"><img src="http://www.example.com/logo.gif" alt="Name of Business" width="100" height="100"></a>
</td>
</tr>
</tbody>
</table>
</div>
<button onclick="copyToClipboard('#email-signature')">Copy to Clipboard</button>
<div id="success" style="display:none; border: 1px solid red; padding:10px; margin-top: 10px;"><strong>Success</strong></div>