简体   繁体   English

在邮件链接的 email 正文中包含参数化的 URL

[英]Include paramerised URL in email body of a mailto link

I have a Javascript variable fullurl which is a url of the form http://example.com/page.php?id=123 I have a Javascript variable fullurl which is a url of the form http://example.com/page.php?id=123

I'd like to create a mailto link with this URL in the body我想在正文中创建一个带有此 URL 的 mailto 链接

html += '<a href="mailto:&subject=Test&body=' + fullurl +'">Click here</a> to email this link';

The result is an email with the body of just http://example.com/page.php so I imagine it is the?结果是一个 email 的主体只是http://example.com/page.php所以我想它是? in the URL throwing it off, as it interprets it as the end of the body= part of mailto在 URL 中将其丢弃,因为它将其解释为 body 的结尾 = mailto 的一部分

You could try to use encodeURIComponent.您可以尝试使用 encodeURIComponent。

fullurl = encodeURIComponent("http://example.com/page.php?id=123")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM