with html5 and a decent web browser you can now create desktop notifications...
so even if the browser is not in focus you can show things like: you have 1 new message :D
heres a Demo: http://something-else.wen.su/notification.html
and here is the script:
so even if the browser is not in focus you can show things like: you have 1 new message :D
heres a Demo: http://something-else.wen.su/notification.html
and here is the script:
PHP Code:
<html>
<head>
<script type="text/javascript">
//request permission
function RequestPermission (callback)
{
window.webkitNotifications.requestPermission(callback);
}
//notify
function notification ()
{
if (!window.webkitNotifications)
{
alert('Get A Better Browser ;) Try Google Chrome');
return;
}
if (window.webkitNotifications.checkPermission() > 0) {
RequestPermission(notification);
}
var icon = 'http://something-else.wen.su/icon.png';
var title = 'New Message';
var body = 'You Have a new message :D';
var popup = window.webkitNotifications.createNotification(icon, title, body);
popup.show(); //open noticication
setTimeout(function(){ //set timer
popup.cancel(); //close noticication
}, '15000'); //time of 15000 milliseconds
}
//html notify
function htmlnotification ()
{
if (!window.webkitNotifications)
{
alert('Get A Better Browser ;) Try Google Chrome');
return;
}
if (window.webkitNotifications.checkPermission() > 0) {
RequestPermission(HTMLnotification);
}
var popup = window.webkitNotifications.createHTMLNotification('http://something-else.wen.su/');
popup.show(); //open noticication
setTimeout(function(){ //set timer
popup.cancel(); //close popup
}, '15000'); //time of 15000 milliseconds
}
</script>
</head>
<body>
<button onclick="notification()">Create Notification</button><br/>
<button onclick="htmlnotification()">Create html Notification</button><br/>
</body>
</html>
Comment