我需要能够在桌面的右下角显示通知弹出窗口,而不是像toastr一样的浏览器窗口的右下角,需要是桌面右下角。我已经看到它完成了我想但不记得在哪里。
有人有任何想法吗?
我猜javascript / jquery?
答案 0 :(得分:1)
您正在寻找通知(),如果用户授予网站使用权限,则可以执行此操作。
链接的DOCS:
<button onclick="notifyMe()">Notify me!</button>
function notifyMe() {
// Let's check if the browser supports notifications
if (!("Notification" in window)) {
alert("This browser does not support desktop notification");
}
// Let's check whether notification permissions have already been granted
else if (Notification.permission === "granted") {
// If it's okay let's create a notification
var notification = new Notification("Hi there!");
}
// Otherwise, we need to 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") {
var notification = new Notification("Hi there!");
}
});
}
// At last, if the user has denied notifications, and you
// want to be respectful there is no need to bother them any more.
}