noty({
layout: 'topRight',
type: 'alert',
text: 'Number of Alerts:'+count,
template: '<div class="noty_message"><span class="noty_text"></span></div>',
closeWith: ['button'],
dismissQueue: true,
animation: {
open: {height: 'toggle'},
close: {height: 'toggle'},
easing: 'swing',
speed: 500
},
timeout: false
});
有没有办法使通知成为可点击的超链接。我考虑过callback onClose()
但由于我不想关闭通知,所以我无法使用它。是否有回调,即onclick
?或者我必须用另一种方式来做。比如在文本中添加超链接?
最佳答案
您可以使用 buttons
选项创建一个在新窗口中打开 URL 的按钮。
noty({
layout: 'topRight',
type: 'alert',
text: 'Number of Alerts:'+count,
template: '<div class="noty_message"><span class="noty_text"></span></div>',
closeWith: ['button'],
dismissQueue: true,
animation: {
open: {height: 'toggle'},
close: {height: 'toggle'},
easing: 'swing',
speed: 500
},
timeout: false,
buttons: [
{
addClass: 'css-class-for-the-btn', text: 'Link', onClick: function ($noty) {
window.open("http://yoururl/");
}
}
]
});
您可以通过在 addClass
中定义类来自定义按钮的 CSS
关于javascript - 使noty通知成为可点击的超链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22220841/