我正在尝试使用html文件创建电子邮件模板。此文件将显示mailto链接列表,单击该链接时将打开带有消息的模板。我让它在大多数情况下工作,但是这些模板中的一些使用提示在创建消息之前向消息添加信息。问题是它似乎不能正常工作。这是我的代码。
function sendReport(emailName, addresseList){
document.writeln('<a onClick="setPrompt(this,\'' + addresseList + '\')" href="mailto:' + addresseList + '?subject=' + 'Report' + '&body=' + 'Here is the report.' + '">' + emailName + '</a><br />');
}
function setPrompt(obj, addresseList){
var reportName = prompt("Report name","");
obj.attr('href', ='mailto:' + addresseList + '?subject=' + reportName + '&body=' + "Here is the report."); //<-- this is the line that is giving me trouble.
}
答案 0 :(得分:1)
您在最后一行中输入了拼写错误,并且Javascript中没有内置.attr()
功能。这应该解决它:
obj.setAttribute('href', 'mailto:' + addresseList + '?subject=' + reportName + '&body=' + "Here is the report.");