是否可以在自定义引导箱中添加 mailto link?

Is it possible to add mailto link inside custom bootbox?

我想知道是否可以将 <a href="mailto:someone@yoursite.com">Email Us</a> 添加到自定义引导盒?我希望用户可以选择单击电子邮件 link。我目前正在使用:

function dbError() {
var box = bootbox.dialog({
    message: "There is currently a problem when trying to connect to the Database. Please try again or contact "'<a href="mailto:someone@yoursite.com">Email Us</a>'" to resolve this issue if it persists.",
    title: "Database Error"
});
box.find('.modal-title').css({ 'color' : 'red' });
};

如果我删除 <a href="mailto:someone@yoursite.com">Email Us</a>,这可以正常工作。任何帮助或建议表示赞赏。谢谢!

你可以像这样与 javascript 混合使用

bootbox.alert('after this it will link to mailto: script', function() {
    document.location.href = "mailto:toon@bluewindsolution.com";
});

您的消息字符串导致错误 - 特别是此处:

"...Please try again or contact "'

当您关闭双引号 " " 时,javascript 将其读取为字符串的末尾并期望 ;+ 否则将引发错误.

小修复:)

var a = '<a href="mailto:someone@yoursite.com">Email Us</a>';

var message = "There is currently a problem when trying to connect to the Database." +
    " Please try again or contact " + a + " to resolve this issue if it persists."


var box = bootbox.dialog({
    message: message,
    title: "Database Error"
});

片段:

var a = '<a href="mailto:someone@yoursite.com">Email Us</a>';


var message = "There is currently a problem when trying to connect to the Database." +
    " Please try again or contact " + a + " to resolve this issue if it persists.";
    

var box = bootbox.dialog({
    message: message,
    title: "Database Error"
});
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<link href="http://bootboxjs.com/css/main.css" rel="stylesheet"/>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet"/>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<script src="http://bootboxjs.com/bootbox.js"></script>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="myModal" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <!-- dialog body -->
            <div class="modal-body">
                <button type="button" class="close" data-dismiss="modal">&times;</button>Send Emails to:</div>
            <!-- dialog buttons -->
            <div class="modal-footer">
                <button type="button" class="btn btn-primary">OK</button>
            </div>
        </div>
    </div>
</div>