支持自动重定向 Toast通知 jQuery通知

  • 源码大小:6.73KB
  • 所需积分:1积分
  • 源码编号:19JP-3300
  • 浏览次数:529次
  • 最后更新:2023年05月28日
  • 所属栏目:其他
本站默认解压密码:19jp.com 或 19jp_com

简介

一个小巧但可自定义的toast通知jQuery插件,允许在倒计时结束时自动将当前页面重定向到另一个URL。

如何使用它:

1.插入主脚本通知.js在jQuery之后。

  1. <script src="/path/to/cdn/jquery.min.js"></script>
  2. <script src="/path/to/notifications.js"></script>

2.初始化插件,并在JS数组中指定toast消息,如下所示:

  1. // Single Toast Notification
  2. $.notification(
  3. ["This is a toast message"],
  4. {
  5. // options here
  6. }
  7. )
  8.  
  9. // Multiple Toast Notifications
  10. $.notification(
  11. ["Toast Message 1", "Toast Message 2"],
  12. {
  13. // options here
  14. }
  15. )

3.设置吐司通知的位置。

  1. $.notification(
  2. ["This is a toast message"],
  3. {
  4. position: ['top', 'right'],
  5. }
  6. )

4.以毫秒为单位指定超时,这意味着toast消息将在此超时后自动解除。默认值:4000。

  1. $.notification(
  2. ["This is a toast message"],
  3. {
  4. timeView: 5000,
  5. }
  6. )

5.指定通知类型:

  • 成功
  • 警告
  • 错误
  1. $.notification(
  2. ["This is a toast message"],
  3. {
  4. messageType: 'success',
  5. }
  6. )

6.确定在toast消息被解除时是否自动重定向当前页面。

  1. $.notification(
  2. ["This is a toast message"],
  3. {
  4. redirectAction: 'https://www.jqueryscript.net'
  5. }
  6. )

预览截图