It really is as simple as creating a CSS style for a div, something like this:
div.notification
{
position: fixed;
top: 0px;
left: 0px;
right: 0px;
height: 20px;
z-index: 1000;
}
and then when you want to show a notification, you add a div with this class to the DOM. For example using jQuery:
function displayNotification(text)
{
var notification = $('<div></div>')
.addClass('notification')
.text(text)
.click(function() { notification.remove(); });
$('body').append(notification);
}
displayNotification('Hello World!');
Of course, you can make it more advanced, but this is the main idea.
source
share