jquery noty on close goto a url

jquery noty on close goto a url

本文关键字:url goto close noty on jquery      更新时间:2023-09-26

我正在使用jQuery noty插件,当有人单击弹出窗口时,我希望它转到URL(如下(,但我无法弄清楚...有人可以给我一个快速的解决方案..?

我希望它转到的URL:script.php?hidenoty=true

<script type="text/javascript">
  function generate(layout) {
    var n = noty({
        text: "<?php echo $motd?>",
        type: 'warning',
        dismissQueue: true,
        layout: layout,
        theme: 'defaultTheme',
        animation: {
        open: {height: 'toggle'},
        close: {height: 'toggle'},
        easing: 'swing',
        speed: 500 // opening & closing animation speed
        },
        timeout: false, // delay for closing event. Set false for sticky notifications
        force: false, // adds notification to the beginning of queue when set to true
        modal: false,
        maxVisible: 3, // you can set max visible notification for dismissQueue true option
        closeWith: ['click'], // ['click', 'button', 'hover']
        callback: {
        onShow: function() {},
        afterShow: function() {},
        onClose: function() {
        $.ajax({ url: 'script.php?hidenoty=true' });
        },
        afterClose: function() {}
        },
        buttons: false // an array of buttons
    });
        console.log('html: '+n.options.id);
  }
  function generateAll() {
    generate('topCenter');
  }
  $(document).ready(function() {
        generateAll();
  });
</script>

更改此行...

$.ajax({ url: 'script.php?hidenoty=true' });

对此...

window.location.href = 'script.php?hidenoty=true';

ajax专门用于在不更改页面的情况下加载某些内容,因此与您想要的相反:)