peng14

 

 原创:

//点击时开启提醒

$(".message_alert").toggle(function(){
$(".message_alert_tip").html("关闭提醒");
$(".message_alert").find("img").attr("src","public/images/bell_open.png")
initNotificatoin(); //打开浏览器开启桌面提醒询问

},function(){
$(".message_alert_tip").html("开启提醒");
$(".message_alert").find("img").attr("src","public/images/bell_close.png")
alert("要关闭桌面提醒,请设置弹框窗口的右上角按钮");
})

//调用弹出框
systemNotify(icon,title,content) ;
//打开系统消息 
function initNotificatoin(){
if (window.webkitNotifications) {
window.webkitNotifications.requestPermission();
}else{
alert("您的浏览器不支持桌面提醒,请使用谷歌浏览器");
}
}
//系统消息 
function systemNotify(icon,title,content) {
if (window.webkitNotifications) {
if (window.webkitNotifications.checkPermission() == 0) {
var icon="public/images/service.png";
var popup = window.webkitNotifications.createNotification(icon, title, content);
popup.ondisplay = function(event) {
setTimeout(function() {
event.currentTarget.cancel();
}, 5000);
}
popup.show();
} else {
window.webkitNotifications.requestPermission();
return;
}
}
}

分类:

技术点:

相关文章:

  • 2021-11-08
  • 2021-07-01
  • 2021-10-12
  • 2021-09-27
  • 2021-09-20
  • 2022-03-02
  • 2022-12-23
猜你喜欢
  • 2022-01-11
  • 2021-06-15
  • 2021-12-01
  • 2021-12-26
  • 2021-05-03
  • 2021-05-26
  • 2021-12-12
相关资源
相似解决方案