WebKit支持本地通知

Posted by admin on April 29, 2010 in 浏览器 |

如需转载,请注明出处!
WebSite: http://www.jjos.org/
作者: 姜江 linuxemacs@gmail.com
QQ: 457283

WebKit项目最近增加了一个新的API,该API可以实现HTML控制桌面通知的功能。该特性可以用于邮件到达通知、日历通知、任务管理、系统监控等多个方面。不过在使用该API之前,需要用户授权。

下面这个网址是老外写的一个WebKit Notification Demo

http://0xfe.muthanna.com/notifyme.html

用最新版本的chrome浏览器访问以上连接,点击Request Permission按钮,允许浏览器访问桌面通知。然后,点击Notify Me按钮,看是不是有“Hello Desktop!”消息弹出?

为了支持桌面通知效果WebKit中新增了webkitNotification对象,通过该对象可以检查浏览器是否支持通知功能、创建通知、获得访问权限、关闭通知等操作。


// 判断是否支持通知功能
if (window.webkitNotifications)
return true;
else
return false;

// 请求获取桌面通知访问权限
window.webkitNotifications.requestPermission(function() {});

// 创建通知,并且显示
var notify = window.webkitNotifications.createNotification(icon, title, body);
notify.show();

~~~ END ~~~


Post Footer automatically generated by wp-posturl plugin for wordpress.

Tags: , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Copyright © 2010 Jelly's Blog All rights reserved.
Desk Mess Mirrored v1.7.2 theme from BuyNowShop.com.

Jelly's Blocnzz&51la for wordpress,cnzz for wordpress,51la for wordpress