I have a web page that makes an Ajax call to my server (using javascript) that returns html formatted text that I want to insert into the local clipboard so that the user can then paste (ctrl-v) it into either their email or calendar application. The text that I am copying to the clipboard will not be displayed on the user interface. Using clipboard.js I have successfully managed to get the html into the clipboard but when I paste it to either outlook or gmail I see the html source code rather than the formatted code. I would like this to work on as many browsers as possible (including mobile).
Below is a simplified version of the javascript that I am currently using:
$.ajax({
type: "Get",
url: "/GetFormattedHtml",
data: JSON.stringify({ "user": user }),
contentType: "application/json; charset=utf-8",
success: function (res) {
var clipboard = new Clipboard(obj, {
text: function () {
return "<i>" + res.MessageStatusText + "</i>";
}
});
clipboard.on('success', function (e) {
console.log(e);
});
clipboard.on('error', function (e) {
console.log(e);
});
//clipboard.destroy();
}
});