Notification
的只读属性icon使得包含icon
的 URL 被显示成通知的一部分,如同指定Notification()
构造函数中icon
的属性。
Note: 此特性在 Web Worker 中可用。
语法
var icon = Notification.icon;
值
一个 USVString
。
示例
在此示例中,当我们想要发出一个通知时,我们运行一个简单的 spawnNotification() 函数
——这是传递参数来指定我们想要的主体、图标和标题,然后它创建必要的options
对象,并使用Notification()
构造函数来触发通知。
function spawnNotification(theBody,theIcon,theTitle) {
var options = {
body: theBody,
icon: theIcon
}
var n = new Notification(theTitle,options);
}
Specifications
Specification | Status | Comment |
---|---|---|
Notifications API icon |
Living Standard | Living standard |
浏览器兼容性
BCD tables only load in the browser
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.