[英]Why notification message is not working in IE11
我試圖在 IE11 中顯示通知消息,但無法正常工作。 IE 可以使用任何其他方法來顯示通知消息。 如果有人知道請幫助找到解決方案。
if(!("Notification" in window)){
console.log("Browser not supported");
}else if(Notification.permission === "granted"){
console.log("Show content for New Message");
}
因為IE不支持notification
API:
https://developer.mozilla.org/en-US/docs/Web/API/notification#Browser_compatibility
我建議您自己放棄對 IE 的支持,因為甚至 Microsoft 也不再支持它。 它的市場份額遠低於 1.5%,通常不再值得。
一種簡單的方法是在舊瀏覽器上使用alert()
,例如:
if(!("Notification" in window)){
console.log("Browser not supported");
alert("my message");
}else if(Notification.permission === "granted"){
console.log("Show content for New Message");
};
否則,如果您正在尋找比這更好的用戶體驗,您可以將消息寫入頁面。
僅在受支持的地方使用該功能也是一個合理的決定。 使用 IE 的人不太可能期待來自瀏覽器的通知!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.