是否可以在自定义bootbox中添加mailto链接?

时间:2015-04-24 22:32:50

标签: html twitter-bootstrap-3 bootbox

我想知道是否可以将src/main/java/...添加到自定义启动箱?我希望用户可以选择单击电子邮件链接。我目前正在使用:

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

如果删除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' }); }; ,这样就行了。任何帮助或建议表示赞赏。谢谢!

2 个答案:

答案 0 :(得分:3)

您的消息字符串导致错误 - 特别是在这里:

"...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>

答案 1 :(得分:0)

你可以通过混合使用像这样的

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