收藏了一段Web聊天提示代码,分享一下!!
<script type="text/javascript">
function check() {// Let's check if the browser supports notifications
if (!("Notification" in window)) {
alert("This browser does not support desktop notification");
}
if (Notification.permission !== "granted") {
Notification.requestPermission(function (permission) {
// Whatever the user answers, we make sure we store the information
if (!('permission' in Notification)) {
Notification.permission = permission;
}
});
}
}
function notifyMe() {
check();
if (1 == 2) {
var notification = new Notification("Hi there!");
}
else {
var notification = new Notification('新的消息', {
icon: 'https://developer.cdn.mozilla.net/static/img/opengraph-logo.dc4e08e2f6af.png',
body: "Hey there! You've been notified!",
});
notification.onclick = function () {
window.open("http://blog.csdn.net/liunianqingshi");
};
}
}
</script>