Mailto与Jquery的链接 [英] Mailto link with Jquery

查看:51
本文介绍了Mailto与Jquery的链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站上有一个mailto链接,工作正常。但是,我想在其上执行.click()事件,以便在用户单击该链接时进行记录。我有.click事件工作并执行ajax请求,但现在mailto链接无法打开电子邮件客户端。是否可以在客户端打开之前运行jquery函数,但仍然打开客户端?

I have a mailto link on my site that is working fine. However, I want to perform a .click() event on it to log when the user clicks that link. I have the .click event working and performing the ajax request, but now the mailto link doesn't open the email client. Is it possible to run a jquery function before the client opens, but still make the client open?

这里是我的代码(它只是打开一个空白窗口浏览器)

here is the code I have (it just opens a blank window in the browser)

<script type='text/javascript'>
                    jQuery('span.email a').on('click',function (){
                        jQuery.ajax({
                            type: 'POST',
                            url: '', //url here
                            data: {comment: 'Email Sent', category : 'EE', store_id: '" . $this->store_id . "'},
                            success: function (data){jQuery('#alerts').html(data);}
                        });
                    window.location.href= $(this).prop('href');
                });
                </script>


推荐答案

您不需要 window.location.href = $(this).prop('href'); 。如果你只是让点击继续正常,它应该做你想要的。

You don't need the window.location.href= $(this).prop('href');. If you just let the click continue on as normal, it should do what you want.

这篇关于Mailto与Jquery的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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