This jQuery plugin is useful for displaying text, images, or both in a notification box that floats overtop of web page. We built this plugin using the jQuery library and have licensed the plugin under both MIT and GPL licenses.
This plugin is easy to use and features several options to allow you to customize it for your site. We have taken user input and developed this plugin to be as robust as possible.
We have introduced API methods that can be used to interact with jQuery.showMessage. Currently there is only a close method, but if we have more interest we will continue to build in more.
A first attempt at a jQuery plugin. This jQuery plugin was inspired by a similar effect seen on the Twitter.com site.
Download the plugin, unzip the contents, and include showMessage script and stylesheet in your document. This is a jQuery plugin, so make sure you also have loaded the jQuery library.
You will need to load jQuery and this plugin JavaScript. You can load jQuery directly from your host or you can use a CDN.
You can style the text, or the responses that are displayed through an unordered list in the div with id attribute showMessage. Further more you can apply the class of your choice to the notification.
Your message can be plain text, html, images or any combination of all three. The message should be pushed to the plugin via an array. Here is an example of how to define an array for the message.
You can attach the notification to the document, and element on the page or use a attribute of an element to attach notification to a specific element.
The following attached the notification to the document.
You can customize the plugin by passing options as a key/value object to showmessage() method.
Key | Value | Default Value | Description |
---|---|---|---|
thisMessage | Array | Empty Array | The message you will be returning to the page. The message is in the form of an array. |
className | String | 'notification' | Customize the style for the notification bar here. |
position | String | 'fixed' | Notification bar css position. Use any of the valid position property values ['fixed','absolute','static','relative','inherit']. |
zIndex | Integer | 1001 | The z-index of the notification bar. Value is an integer greater then one. |
opacity | Integer | 90 | Opacity of the notification bar. Value is an integer between 1 and 100. |
location | String | 'top' | Position of the notification bar. Value can be either 'top' or 'bottom' only. |
useEsc | Boolean | true | Will bind the 'Esc' keydown event to window to close the notificaton bar. |
displayNavigation | Boolean | true | Will display the navigation close text information in upper right. |
autoClose | Boolean | false | When set to true, it will close the notification bar after specified delay time. |
delayTime | Integer | 5000 | Amount of time in milli-seconds before the notification bar will close/hide (autoClose must be set to true). |
closeText | String | 'close' | Text that you want the notification to display in upper right to close window. |
escText | String | 'Esc Key or' | Text that you want the notification to display in upper right to close window with 'Esc' key. |
We have just started working on public functions to help you utilize the plugin in a number of different scenarios. These functions can be called as a property of the $.showMessage object. To use from inside the iframe -
<a href="javascript:parent.$.showMessage.close();">Close message</a>
Name | Description |
---|---|
close |
$.showMessage.close()
This will close the notification and clear 'autoClose' if it exists |
We have created a few examples of how the plugin can be used below
Call the method with an event like a click!.
You can validate a form (client side or server side) using JavaScript and an Asynchronous call.
You can open the notification on just about any element. This example shows how we can display message in a modal window.
Note that the modal window we opened has an attribute id="testModal".You can attach the notification to the document, and element on the page or use a attribute of an element to attach notification to a specific element.
Mouse over the link to view an excessively pretentious tooltip.