安全上下文
此特征只可用于
安全上下文
(HTTPS),在某些或所有
支持浏览器
.
onclick
特性为
Notification
interface specifies an event listener to receive
click
events. These events occur when the user clicks on a displayed
Notification
.
Notification.onclick = function(event) { ... };
The default behavior is to move the focus to the viewport of the notification's related
浏览上下文
. If you don't want that behaviour, call
preventDefault()
on the event object.
In the following example, we use an onclick handler to open a webpage in a new tab (specified by the inclusion of the
'_blank'
parameter) once a notification is clicked:
notification.onclick = function(event) {
event.preventDefault(); // prevent the browser from focusing the Notification's tab
window.open('http://www.mozilla.org', '_blank');
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
Notifications API
The definition of 'onclick' in that specification. |
实时标准 | Living standard. |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
onclick
|
Chrome Yes | Edge 14 | Firefox 22 | IE No | Opera Yes | Safari Yes | WebView Android No | Chrome Android Yes | Firefox Android No | Opera Android Yes | Safari iOS No | Samsung Internet Android Yes |
完整支持
不支持
Notification