正在尝试将标题标记添加到mailto链接,正文中包含URL
Trying to add the title tag to a mailto link, with the URL in the body
我正在为我们的产品创建一个帮助网站。它将由我们的客户服务小组在网络上部署(针对登录的客户),并将与我们的软件一起部署。我们想创建一个反馈机制,但我们不能使用服务器端脚本,因为在某些情况下,用户将在本地查看帮助网站。
我们正在研究一个长期的解决方案,但目前我们正在尝试使用一个简单的<a href="mailto">
链接(我们已经将其格式化为按钮):
<p class="docfeedback"><a href="mailto:example@example.com?subject=Documentation Feedback" title="We welcome your feedback on this documentation. If you cannot send mail from this server, please send your feedback to: example@example.com>
我想要的是获得<title>
元素的值,并将其放在Subject中,我想要在正文行中获得url路径名(仅路径名)。
我已经阅读了几个答案,这些答案为我提供了部分解决方案,但我希望将它们放在一起,并以正确的方式进行编码。
我一直在读关于使用javascript获取URL的文章,我能够在消息正文中成功地做到这一点。但后来我试着用这个答案把主题中的第一个H1作为信息的主题。然后我将其更改为title
元素。(我的项目可以自动访问jquery[1.8.3],所以我不必专门调用它。)
所以,这是有效的,但我不知道如何将两者结合在一起。这是我的HTML中的当前代码。
<script>
$(document).ready(function(){
var mailtoHref = $('#mailme a').attr('href'); //get href
var h1Text = $('title').text(); //get h1 text
$('#mailme a').attr('href', mailtoHref + h1Text ); //append it to mailto://
});
</script>
<div id="mailme">
<p class="docfeedback">
<a href="mailto:example@example.com?subject=Documentation Feedback for topic: " title="We welcome your feedback on this documentation. If you cannot send mail from this server, please send your feedback to: example@example.com">Send us documentation feedback</a>
</p>
</div>
p.docfeedback /* only used on master page for feedback link */
{
text-align: center;
font: bold 11px Arial;
text-decoration: none !important;
background-color: #EEEEEE;
padding: 5px 9px 5px 9px;
border: 1px solid #CCCCCC;
border-radius: 10px;
width: 225px;
}
p.docfeedback a:link,
p.docfeedback a:visited,
p.docfeedback a:hover,
p.docfeedback a:active
{
color: #666;
text-decoration: none !important;
}
<head>
<title>This is the name of the document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
</head>
<script>/* <![CDATA[ */
$(document).ready(function(){
var mailtoHref = $('#mailme a').attr('href'); //get href
var h1Text = $('title').text(); //get h1 text
$('#mailme a').attr('href', mailtoHref + h1Text ); //append it to mailto://
});
/* ]]> */</script>
<div id="mailme">
<p class="docfeedback"><a href="mailto:example@example.com?subject=Documentation Feedback for topic: " title="We welcome your feedback on this documentation. If you cannot send mail from this server, please send your feedback to: example@example.com">Send us documentation feedback</a>
</p>
</div>
如果你能提供任何帮助,我将不胜感激。
jQuery用于将当前url添加到电子邮件正文,位于下方
$(document).ready(function() {
var url = window.location.href; //get url
var h1Text = $('title').text(); //get h1 text
var email = 'example@example.com';
var body = url;
var subject = 'Documentation Feedback for topic: '+h1Text;
var hrefTitle = 'We welcome your feedback on this documentation. If you cannot send mail from this server, please send your feedback to: '+email;
$('#mailto').attr('href','mailto:'+email+'?body='+body+'&subject='+subject);
$('#mailto').attr('title', hrefTitle);
});
html mailto链接现在是这样的
<a id="mailto" href="" title="">Send us documentation feedback</a>
完整代码在这里https://jsfiddle.net/50c99uan/2/
相关文章:
- 正在尝试将标题标记添加到mailto链接,正文中包含URL
- 如何在实时网页中用mailto链接替换电子邮件地址
- 如何通过mailto在电子邮件中突出显示链接
- facebook墙上的MailTo链接(phonegap)
- 使用Mailto链接,如果可能的话,我可以在Outlook邮件正文中添加当前页面吗?在 asp.net
- mailto HTML 电子邮件链接与动态构建的主题
- CF-Hash属性和脚本神秘地添加到mailto链接中
- 我的 mailto 链接中的换行符在 Android 手机上已损坏
- "+"登录JS mailto链接(Android和Chrome)
- Mailto或超链接不会;由于子菜单脚本,无法处理页脚菜单
- 可以't在mailto链接后关闭引导模式
- Gmail签名不适用于mailto链接
- 使用mailto Javascript向电子邮件添加本地文件的链接
- jQuery数组填充mailto链接添加逗号
- 基于多个复选框选择,“mailto:”链接使用javascript更改为“mailto: Multiple variab
- 在Javascript中使用href=mailto链接图像
- 如何在Joomla的WYSIWYG编辑器中的mailto链接中包含&号?
- encodeuriccomponent,同时构造mailto链接
- 检测基于web的邮件客户端与本地邮件客户端的mailto链接
- 为什么用转义字符的mailto链接不被雅虎邮箱识别?