当文本放入邮件正文时,所有都会从字符串中删除。
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);