External (desktop) notification message box shells

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>测试页面</title>
</head>
<body>

<Button onclick = "onNotice ( 'acceptance libraries', 'HelloWord')"> This is a button </ button>

</body>
<script>

onNotice function (title, body) {
IF (( "the Notification" in window)!) {
Alert ( "not supported Notification");
} the else IF (Notification.permission === "granted") {// permission notice
Notice ( title, body)
} the else iF (Notification.permission! == 'denied') {// user does not select whether to display the notification, the user requests permission
Notification.requestPermission (function (permission) {
iF (permission === "granted" ) {
Notice (title, body)
}
});
}
}

function notice(title,body) {
var notification = new Notification(title,{
body:body,
icon:"https://mp.weixin.qq.com/misc/getheadimg?token=990524500&fakeid=3006291623&r=674680"
});
notification.onclick = function(){
window.open("http://120.79.14.150:8080/");
};
setTimeout(function () {
notification.close();
},3000);
}

</script>
</html>

Guess you like

Origin www.cnblogs.com/nengnengc-nnc/p/12537012.html