gpt4 book ai didi

javascript - 如何更改javascript中的弹出标题?

转载 作者:行者123 更新时间:2023-12-03 05:03:03 25 4
gpt4 key购买 nike

您能告诉我如何更改弹出的标题吗?目前它显示的是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);
}

最佳答案

您需要查看通知constructor

第一个参数。是标题和第二个参数。是一个对象,指定其他详细信息,包括消息的正文。因此您需要这样的内容

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

关于javascript - 如何更改javascript中的弹出标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42135863/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com