javascript - 如何在 mailto 正文中附加 Javascript 代码

标签 javascript html mailto

我的代码如下,当邮箱打开时,JS 代码片段会中断。

<a href="mailto:?subject=This is My Subject&body=Hithis is my text and my page url is"+window.location.href+\" click link to see Greater experienceto" target="_top" class="">

Email

我希望它在页面中可用链接的地方动态显示 url。 Expected email

最佳答案

尝试这样:

<a href="#" onclick="javascript:window.location='mailto:?subject=Interesting information&body=I thought you might find this information interesting: ' + window.location + ' click link to see Greater experienceto'">Click</a>

关于javascript - 如何在 mailto 正文中附加 Javascript 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45596873/

相关文章:

javascript - Webkit 浏览器(Chrome 和 Safari)不喜欢 mailto?

javascript - 调整一个 div 的大小应按比例调整其他 div 的大小

javascript - 使用单独 header 中的 JavaScript 验证表单

javascript - 如果所有三个单选按钮均为 false,则不验证

javascript - 如何创建一个 mailTo 链接,其正文包含包含转义值的链接

php - 将http请求重定向到mailto请求

javascript - 使用 Jest 模拟 Firebase onValue 函数

javascript - 一些 openweathermap API 示例代码出现问题

html - CSS Sprite 链接无效

javascript - 用空跨度隐藏 li