jQuery消息提示插件growl-notification,該插件提供漂亮的UI效果,和多種主題,支持自定義消息框的彈出位置等,使用簡單方便。
內置漂亮的 UI 效果和多種主題、
輕量級,壓縮后只有 18K。
純 js 編寫,沒有任何依賴。
支持 IE11+, Safari, Google Chrome, Yandex Browser, Opera, Firefox。

使用方法
在頁面中引入下面的文件。
<link href="light-theme.min.css" rel="stylesheet"> <script src='growl-notification.min.js'></script>
初始化插件
GrowlNotification.notify({
title: 'This is title',
description: 'My Description'
});配置參數
GrowlNotification.notify({
margin: 20,
type: 'default',
title: '',
description: '',
image: {
visible: false,
customImage: ''
},
closeTimeout: 0,
closeWith: ['click', 'button'],
animation: {
open: 'slide-in',
close: 'slide-out'
},
animationDuration: .2,
position: 'top-right',
showBorder: false,
showButtons: false,
buttons: {
action: {
text: 'Ok',
callback: function() {}
},
cancel: {
text: 'Cancel',
callback: function() {}
}
},
showProgress: false
});| 參數 | 默認值 | 描述 |
|---|---|---|
| width: number|string | null | 消息通知框的寬度,例如 100px, 50%... |
| zIndex: number | 1056 | 消息通知框的 z-index |
| type: string | 'alert' | alert, success, error, warning, info |
| position: string | 'top-right' | top-left, top-right, bottom-left, bottom-right, top-center, bottom-center |
| title: string | '' | 標題,可以包括 HTML 內容(input 元素除外) |
| description: string | '' | 描述,可以包括 HTML 內容(input 元素除外) |
| image.visible: boolean | false | 顯示隱藏圖片 |
| image.customImage: string | '' | 自定義圖片的路徑 |
| closeTimeout: boolean,int | false | 延遲關閉對話框的時間,單位毫秒。 |
| closeWith: [...string] | ['click'] | click, button |
| animation.open: string,null,false | 'slide-in' | 如果是 string, 表示使用 css 類名. 如果是false|null|'none', 不會使用動畫效果。 'slide-in', 'fade-in' |
| animation.close: string,null,false | 'slide-out' | I 如果string,表示使用 css 類名. 如果是 false|null|'none',不會使用動畫效果。 'slide-out', 'fade-out' |
| showButtons: true,false | false | 顯示或隱藏按鈕。 |
| buttons: object | buttons: {
action: {
text: 'Ok',
callback: function {} // callback
},
cancel: {
text: 'Cancel',
callback: function {} // callback
}
} | Buttons configuration |
| showProgress: true,false | false | 顯示或隱藏進度條 |
| GrowlNotification.setGlobalOptions: object | {} | 為消息框設置全局參數。 |
| GrowlNotification.closeAll | - | 關閉所有消息框。 |






