function notify(msg, delay) {
var box = document.createElement('DIV');
box.id = 'notification';
// you should just style #notification in css, but w/e
box.style.position = 'fixed';
box.style.bottom = '10px';
box.style.right = '10px';
box.style.width = '200px';
box.innerHTML = msg;
document.body.appendChild(box);
setTimeout(function() {
box.parentNode.removeChild(box);
}, delay);
}
используйте это как:
notify('sup dude', 1000);
Редактировать: Jquery версия:
function notifyJquery(msg, delay) {
$("body").append('<div id="notification" />').css({
'display': 'none',
'position': 'fixed',
'bottom': '10px',
'right': '10px'
}).text(msg).fadeIn(400).delay(delay).fadeOut(400);
}
notifyJquery('sup dude', 1000);