Javascript 消息中有链接的确认对话框?

Javascript 消息中有链接的确认对话框?,javascript,html,dojo,confirmation,Javascript,Html,Dojo,Confirmation,抱歉,如果这是一个愚蠢的问题(我对web开发还是新手),但是否可以在基本确认对话框消息中有一个链接 现在,我有一个基本的确认弹出窗口 if (confirm("Bunch of text here")) ... 但一位客户希望我在确认框中添加一个链接,该链接将在新窗口中打开。在消息中添加html标记不起作用,因为它是一个消息字符串 如有任何建议,将不胜感激 谢谢 您可以创建一个模式并像那样显示它,或者更简单地说,使用bootstrap的内置模式 HTML: <div class="but

抱歉,如果这是一个愚蠢的问题(我对web开发还是新手),但是否可以在基本确认对话框消息中有一个链接

现在,我有一个基本的确认弹出窗口

if (confirm("Bunch of text here"))
...
但一位客户希望我在确认框中添加一个链接,该链接将在新窗口中打开。在消息中添加html标记不起作用,因为它是一个消息字符串

如有任何建议,将不胜感激


谢谢

您可以创建一个模式并像那样显示它,或者更简单地说,使用bootstrap的内置模式

HTML:

<div class="button">Click</div>

<div class="overlay">

    <div class="modal"></div>

</div>
JS:

$(函数(){
变量按钮=$('.button'),
覆盖=$('.overlay'),
消息='消息文本',
模态=$('.modal');
按钮。在('单击',函数()上){
css('display','block');
html(message+“”);
});
});

这在Javascript的
确认功能中是不可能的。为了做到这一点,您需要一个自定义模式对话框

如果您使用jQuery,您可以使用以下方法之一创建一个:,并列举一些

如果不使用jQuery,可以通过为事件应用一些CSS和Java脚本来创建一个jQuery。你也可以跟着

.button {
    background-color: #aa0000;
    color: #fff;
    padding: 5px 40px;
    display: inline-block;
    cursor: pointer;
}

.overlay {
    background-color: rgba(0, 0, 0, 0.8);
    position: fixed;
    height: 100%;
    width: 100%;
    display: none;
    top: 0;
    left: 0;
}
.modal {
    left: 50%;
    margin-left: -100px;
    top: 50%;
    margin-top: -100px;
    background-color: #fff;
    position: fixed;
    height: 200px;
    width: 200px;
}
$(function() {

var button = $('.button'),
    overlay = $('.overlay'),
    message = 'Message text',
    modal = $('.modal');

button.on('click', function() {
    overlay.css('display', 'block');
    modal.html( message + '<a href="http://google.com"' + 'target="_blank">' + 'link' +  '</a>');
});

});