我在asp.net中使用下面的javascript進行桌面通知。在按鈕上單擊此事件可以正常工作,但在執行代碼時會出錯。asp.net中的桌面通知
這個代碼在我的網頁添加...
<script type="text/javascript">
function notifyMe() {
if (!("Notification" in window)) { alert("This browser does not support desktop notification"); }
else if (Notification.permission === "granted") {
var options = {
body: "This is the body of the notification",
icon: "stupidcodes.com.png",
dir: "ltr"
};
var notification = new Notification("Hi there", options);
notification.onclick = function() {
window.open("http://www.stupidcodes.com/");
};
}
else if (Notification.permission !== 'denied') {
Notification.requestPermission(function (permission) {
if (!('permission' in Notification)) {
Notification.permission = permission;
}
if (permission === 'granted') {
var options = {
body: 'This is the body of the notification',
icon: 'stupidcodes.com.png',
dir: 'ltr'
};
var notification = new Notification('Hi there', options);
notification.onclick = function() {
window.open('http://www.stupidcodes.com/');
};
}
});
}
}
是否有添加通知這樣在asp.net
可以通過這個代碼的方法working here
你有這個工作嗎? –
沒有還沒有@SachinTrivedi –