如何防止电子邮件文本中的下一行被删除?



当文本放入邮件正文时,所有都会从字符串中删除。

var valuess = Object.entries(feedBackText);
valuess.forEach(function (key) {
responseText = responseText.concat(' ' + key[0] + ':' + key[1] + 'n');
});

var parsedString = responseText.toString();
window.location = "mailto:myid@gmail.com"+"?subject="+subjectmail+"&body=" + 
parsedString;

下面演示如何使用内置的encodeURIComponent函数解决此问题:

var parsedString = "text on the" + "n" + "next line";
var link = "mailto:myid@gmail.com" + "?subject=Example&body=" +
encodeURIComponent(parsedString);
console.log(link);

最新更新