javascript - 使noty通知成为可点击的超链接

标签 javascript jquery-plugins noty

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/

相关文章:

javascript - 查询 : noty confirmation message

javascript - 我怎样才能让这个脚本变得更好?

javascript - HTML 表格转 Excel,浏览器卡住

javascript - 饼图的标签文本没有出现

javascript - 在 javascript 函数中,你可以设置 this.function = function 吗?

jquery 显示和隐藏通知 - 通知

javascript - 多维 JavaScript 数组语法?

javascript - 为什么占位符在 IE8 中不起作用?

javascript - HTML , Jquery 鱼眼菜单

javascript - Noty(通知库)对话框具有透明背景 - AngularJS Web 应用程序