Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
366 views
in Technique[技术] by (71.8m points)

网页qq的消息提醒怎么实现的?

如何实现网页qq的跨页面的消息提醒?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

html5有个新特性。当有消息是调用这个函数,就可以跨页面消息提示,你可以在控制台测试下
Notification.requestPermission(function(status) {

        //status是授权状态,如果用户允许显示桌面通知,则status为'granted'  
        console.log('status: ' + status);  

        //permission只读属性  
        var permission = Notification.permission;  
        //default 用户没有接收或拒绝授权 不能显示通知  
        //granted 用户接受授权 允许显示通知  
        //denied  用户拒绝授权 不允许显示通知  

        console.log('permission: ' + permission);  
    });  

new Notification("sir, you got a message", {

body: 'you will have a meeting 5 minutes later.'  

});


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
...