javascript - Why webkit notification event does not trigger? -
i have wrote webkit notification script on web app pull notifications database. code seen below
function checknotifications() { if (window.webkitnotifications.checkpermission() == 1) { window.webkitnotifications.requestpermission(); } else { $.ajax({ type: "get", datatype: 'json', url: '/check_notifications', success: function(data){ if (data){ var ticketid = data.ticket_id; console.log(data); var comment = data.comment; var createddate = data.created_at; var notificationcomment = data.comment; var notificationid = data.notifcation_id; var notification = window.webkitnotifications.createnotification('/pt_logo_small.png', 'project ticket '+ticketid+ ' updated!', 'ticket has been updated. click here see!'); notification.show(); console.log(notificationid); notification.onclick = function(){ this.close(); console.log("notification clicked!") $.ajax({ type: "get", datatype: 'json', url: '/read_notifications/' + notificationid, success: function(){ window.location = '/pto/' + ticketid; }, error: function(){ window.location = '/pto/' + ticketid; } }); console.log(ticketid, comment, createddate); }; } } }); } settimeout(checknotifications, 20000); }
for reason. if select tab, or go path inside webapp, script still runs display notifications, .onclick event never triggers.
anyone have idea why wouldn't trigger?
according apple, onclick should bring page created event focus, does. nothing inside .onclick function triggers.
thanks all.
Comments
Post a Comment