javascript - 如何在 'mailto' body 中写入到当前页面的链接

标签 javascript html href

我网站的所有页面中都有 mailto 按钮,我想在电子邮件正文中写入对该页面的引用。

在一页中我可以有

<a class="email" title="Email a friend" href="mailto:?subject=Interesting%20information&amp;body=I thought you might find this information interesting:%20%0d%0ahttp://www.a.com/Home/SiteMap/tabid/589/Default.aspx">Email</a>

但是我怎样才能使所有页面都通用呢?

最佳答案

这是纯 javascript 解决方案:

<a class="email" title="Email a friend" href="#" onclick="javascript:window.location='mailto:?subject=Interesting information&body=I thought you might find this information interesting: ' + window.location;">Email</a>

关于javascript - 如何在 'mailto' body 中写入到当前页面的链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7977165/

相关文章:

javascript - 禁用提交按钮,直到两个输入都不为空

javascript - 将 Babel 与单个输出文件和 ES6 模块一起使用

javascript 验证特殊字符的索引/位置

python - Google App Engine Python If Else 在 Html 模板中的用法

apache - document.location.href 中的特殊字符

CSS 不适用于 Razor 页面中的 asp-page 标签

javascript - 我怎样才能让这个动画在javascript中表现得更好?

javascript - 无法读取未定义的属性 'indexOf'

html - Angular 文件包含和分离 - 最佳实践

internet-explorer-8 - href链接无法在ie 8中运行