代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
Notification.requestPermission()
var notification = new Notification('报修工单', {
body: '您有新的报修工单待审核哦',
icon: 'img/logo.ico'// "图标路径,若不指定默认为favicon"
});
notification.onclick = function(event) {
event.preventDefault(); // 阻止浏览器默认事件
window.open('https://saas.cvoon.com/data/tenement/guarantee/owner', '_blank');
}
</script>
</body>
</html>
通知的其他属性也可自行研究尝试。
具体的学习可以在这儿查看https://developer.mozilla.org/zh-CN/docs/Web/API/notification