我爲我的Web服務發出了通知。代碼如下所示(兩個第一線的精神快捷方式):JavaScript - 瀏覽器中的通知API
check_how_many_alerts();
loop count(check_how_many_alerts){
var n = new Notification("Alert!",{ icon: "alert.png", body: variable });
alert_name = variable;
n.onshow = function() {
setTimeout(n.close.bind(n), 10000);}
n.onclick = function() {
$.ajax({
url: 'notif_accept.php',
type: 'GET',
data: 'id=' + alert_name,
success: function(output)
{
alert('success, server says '+output);
}, error: function()
{
alert('something went wrong');
}
});
}
}
問題是,當我有兩個或兩個以上的警報,個個都在.onclick功能相同的URL。我應該怎樣做才能使URL具有不同的「alert_names」?
不知道網址,你正在談論。顯示的代碼中沒有任何內容涉及URL的 – charlietfl 2014-10-18 11:31:12