来自脚本的mailto不显示友好名称

时间:2018-04-24 04:47:02

标签: javascript

我从我的脚本触发了mailto链接,并且地址未显示的友好名称:

window.open(`mailto:"${name}"<{contactId=${id}}{userId=${this.userId}}{pitchingInitiativeId=${this.pitchingInitiativeId}}@propelmymail.com>`, '_blank');

输出到:

mailto:%22undefined%22%3C%7BcontactId=1%7D%7BuserId=7%7D%7BpitchingInitiativeId=71%7D@propelmymail.com%3E

1 个答案:

答案 0 :(得分:0)

您的输出生成错误,如果应该

window.open(`mailto:"Friendly Name"<actualemail@propelmymail.com>`, '_blank');

在你的输出中有URL编码的字符串,我不知道你使用的是哪个js框架,但在普通的javascript中你可以连接placehoders并使用标准字符串,

var name = 'Friendly Name';id = 10; userId = 1125; pitchingInitiativeId = 55;
window.open(`mailto:"${name}"<${id}${userId}${pitchingInitiativeId}@propelmymail.com>`, '_blank');