[英]how to concatenate string in javascript
我需要将mailto元素转换为在javascript中具有subject和body元素。
var matterDetail = "?Subject=Potential New Matter";
try{strContact = strContact + "<TD><A href=mailto:" + EMailNode.item(0).firstChild.nodeValue +matterDetail +">" + EMailNode.item(0).firstChild.nodeValue + "</A></TD>";}
这<a href="mailto:some@email.com" ?Subject="Potential" Matter="" New="">
html输出到<a href="mailto:some@email.com" ?Subject="Potential" Matter="" New="">
任何想法字符串连接有什么问题吗?
经典的ASP不是用C#编写的,所以我不知道您在使用什么,但是似乎您正在使用C#,所以我会使用string.format:
strContact += string.Format(
"<td><a href=\"mailto:{0}{1}\">{2}</a></td>",
EMailNode.item(0).firstChild.nodeValue,
matterDetail,
EMailNode.item(0).firstChild.nodeValue
);
编辑好吧,我误以为C#的JS!
您的问题是html属性中缺少引号,请尝试以下操作:
strContact += "<td><a href=\"mailto:" + EMailNode.item(0).firstChild.nodeValue +matterDetail +"\">" + EMailNode.item(0).firstChild.nodeValue + "</a></td>";
请注意href属性周围的多余(转义)引号
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.