带有mailto和javascript函数的锚定标记

带有mailto和javascript函数的锚定标记,javascript,jquery,html,dom,Javascript,Jquery,Html,Dom,下面是我的一段代码,我试图调用一个javascript函数和mailto,当用户单击锚链接时,我的javascript函数抛出错误,如果我删除mailto,它工作正常。如果我遗漏了什么,请告诉我 <a rel="nofollow" onclick="javascript:confirm('2R','ADDRESS');return true;" href="mailto:housing@test.edu? subject=Incorrect Residential Address"

下面是我的一段代码,我试图调用一个javascript函数和mailto,当用户单击锚链接时,我的javascript函数抛出错误,如果我删除mailto,它工作正常。如果我遗漏了什么,请告诉我

    <a rel="nofollow" onclick="javascript:confirm('2R','ADDRESS');return true;" href="mailto:housing@test.edu?
subject=Incorrect Residential Address">housing@test.edu (Click Here)</a>
下面是我的确认函数,它具有ajax调用

    function confirm(addcode,type){

     $.ajax({
            url: 'https://mysite.url/confirm',
            dataType: 'json',
            method: 'POST',
            cache : false,
             beforeSend: function setHeader(xhr){
                 console.log(addcode + '<--->'+type+'<--->'+term);
                $("#main-content").mask("Please wait...");
            },
            data: {
                'addCode': addcode,
                'type': type,
                'termCode' : term
            },
            success: function(data){
                notify("Confirmed");
                $("#main-content").unmask(); 
            },
            error: function(xhr, testStatus, error) {
                $("#main-content").unmask(); 
                notify("Unable to Confirm");

                console.log(error);
                console.log(xhr);
                console.log(testStatus);
            }
        });
}
目前无法发表评论: 我认为这不是一个真正的“错误”,更重要的是代码没有按照他期望的那样工作

在激活“mailto:”之前,需要一个确认框。 如果用户按yes,则会激活它。 如果用户按“否”,则您不希望它执行任何操作。 这里有一个交叉浏览器解决方案: jsfiddle:

编辑:
顺便说一句,您不能更改确认框的标题。“确认”函数仅适用于1个参数。如果您坚持制作带有标题的确认框,则应使用第三方脚本或您自己的函数。

什么错误?你能分享一下它的工作原理吗->当然,你需要告诉我们错误并向我们展示javascript代码如果是函数抛出了错误,那么我们需要看到它。确认函数由我在java脚本中定义,它有一个ajax调用,
function mConfirm(e, a)
{
    if (confirm('Are you sure you want to send it to: ' + a + '?'))
    {
        return true;
    }
    else
        e.preventDefault();
}