【问题标题】:how to change the popup title in java script?如何在javascript中更改弹出标题?
【发布时间】:2017-02-09 11:44:56
【问题描述】:

您能告诉我如何更改弹出窗口标题 ..目前显示http:\\s.codepen.io我们可以更改此网址吗?

http://codepen.io/anon/pen/WRaZOq

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("Hi there!");
  }

  // 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("Hi there!");
      }
    });
  }

  // At last, if the user has denied notifications, and you 
  // want to be respectful there is no need to bother them any more.
}Notification.requestPermission().then(function(result) {
  console.log(result);
});function spawnNotification(theBody,theIcon,theTitle) {
  var options = {
      icon: theIcon
  }
  var n = new Notification(theTitle,options);
}

【问题讨论】:

    标签: javascript jquery push-notification notifications service-worker


    【解决方案1】:

    您需要查看通知constructor

    第一个参数。是 title 和第二个参数。是一个指定其他细节的对象,包括消息的body。所以你需要这样的东西

    var notification = new Notification("the title",{body:"body of the notification"});
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-17
      • 2015-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-29
      • 2018-06-11
      • 1970-01-01
      相关资源
      最近更新 更多