浏览器推通知给桌面

复制代码
<!DOCTYPE HTML>
<html>
<body>

Notification

</body>
<script type="text/javascript">
checkNotification();
function checkNotification(){

if (!('Notification' in window)) {

alert('This browser does not support desktop notification');

}

// check whether notification permissions have alredy been granted

else if (Notification.permission === 'granted') {

// If it‘s okay let‘s create a notification

new Notification('Granted!');

}

// Otherwise, ask the user for permission

else if (Notification.permission !== 'denied') {

Notification.requestPermission(function (permission) {

// If the user accepts, let‘s create a notification

if (permission === 'granted') {

new Notification('Request granted!');

}

});

}

}

</script>

</html>
复制代码

 

posted @   李照耀  阅读(270)  评论(0编辑  收藏  举报
编辑推荐:
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
阅读排行:
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
点击右上角即可分享
微信分享提示