如何在实时网页中用 mailto 链接替换电子邮件地址? [英] How to replace email addresses with mailto links in a live web page?

查看:25
本文介绍了如何在实时网页中用 mailto 链接替换电子邮件地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想象一下:您遇到一个网页,上面写着只需向 user@example.com 发送消息",但要实际发送电子邮件,您需要突出显示地址,然后将其剪切并粘贴到您选择的电子邮件客户端的新撰写窗口.

Imagine this: you come across a webpage that says "Just send a message to user@example.com" but to actually send the email, you need to highlight the address and then cut and paste it into the recipient field of a new compose window of your email client of choice.

显然,如果它只是一个 mailto: 链接,生活会更轻松,这样您就可以单击它并自动创建一条新消息.如何构建将电子邮件地址转换为可点击的 mailto: 链接的扩展程序?

Obviously life would be easier if it were simply a mailto: link, so you could click on it and have a new message created automatically. How do I build an extension that turns email addresses into clickable mailto: links?

我原本想询问是否有一个扩展程序可以为未链接的 Twitter @username 提及启用类似的功能,但我认为这个电子邮件地址问题会更简单.

I was originally going to ask if there was an extension to enable similar functionality for unlinked Twitter @username mentions but I thought this email address problem would be a simpler situation.

推荐答案

使用 innerHTML 替换电子邮件 - ,这会破坏页面的,尤其是因为删除了事件侦听器并且还替换了属性.

Use innerHTML to replace the email - No, this breaks page's, especially because event listeners are removed and attributes are also replaced.

递归遍历所有节点:

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆