[英]Confirmation Dialog with Link in message?
抱歉,這是一個愚蠢的問題(我對Web開發還是很陌生),但是在基本的確認對話框消息中是否可以有鏈接?
現在,我有一個基本的確認彈出窗口
if (confirm("Bunch of text here"))
...
但是客戶希望我在該確認框中添加一個鏈接,該鏈接將在新窗口中打開。 在郵件中添加html標簽不起作用,因為它是郵件字符串。
任何建議,將不勝感激。
謝謝!
您可以制作一個模態並像這樣顯示它,或者甚至更簡單些,使用bootstrap內置的模態。
HTML:
<div class="button">Click</div>
<div class="overlay">
<div class="modal"></div>
</div>
CSS:
.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;
}
JS:
$(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>');
});
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.