JavaScript 通知 onclick 事件

bro*_*ode 2 javascript notifications webkit

一旦通知实例化 onclick 函数就会触发,但我想在通知上发生实际点击之前阻止此事件

   var message = new Notification("RandomString");
   message.onclick(alert("Random Message"))
Run Code Online (Sandbox Code Playgroud)

Emi*_*uez 6

尝试这个:

var message = new Notification("RandomString");
message.onclick = function(){alert("Random Message")};
Run Code Online (Sandbox Code Playgroud)