【发布时间】:2019-05-20 20:33:09
【问题描述】:
我们有一个在 ASP.Net 网络表单上运行的网络应用程序。用户进入一个询问一些信息的登录页面,该页面被存储在一个 SQL 数据表中,并通过电子邮件向联络中心发送通知。
我们需要,当一些用户提交表单时,联络中心代理会收到来自浏览器的推送通知。
登录页面位于特定的 URL,例如 www.mysite.com/landing.aspx,联络中心的前端位于 www.mysite.com/admin
到目前为止,我们已经尝试过使用 javascript。我们有一个代码每分钟在数据库中搜索新记录,但它给服务器加载了太多工作!
这是执行一分钟任务后加载的javascript:
window.onload = 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("New form request received!");
}
// 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("New form request received!");
}
});
}
// At last, if the user has denied notifications, and you
// want to be respectful there is no need to bother them any more.
}
</script>
您知道实现此目标的更好方法吗?谢谢!
【问题讨论】:
标签: javascript asp.net webforms