【问题标题】:Is it possible to add mailto link inside custom bootbox?是否可以在自定义引导箱中添加 mailto 链接?
【发布时间】:2015-04-24 22:32:50
【问题描述】:

我想知道是否可以将<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' });
};

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

【问题讨论】:

  • 包含一些演示 html 代码会很有用,这样其他人就可以轻松复制/粘贴您的示例以加快周转速度。

标签: html twitter-bootstrap-3 bootbox


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

    你可以通过像这样与javascript混合来做到这一点

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

    【讨论】:

      猜你喜欢
      • 2010-09-19
      • 1970-01-01
      • 2010-10-22
      • 1970-01-01
      • 1970-01-01
      • 2019-10-22
      • 1970-01-01
      • 2022-10-18
      相关资源
      最近更新 更多