I have this script ajax
that updates the screen and calls the notifyMe()
and the notification is displayed. But I noticed that clicking it opens the page in another tab. I want when I click on the notification it opens on the same tab that this notification was executed and not open a new one.
<script>
// request permission on page load
document.addEventListener('DOMContentLoaded', function () {
if (!Notification) {
alert('Desktop notifications not available in your browser. Try Chromium.');
return;
}
if (Notification.permission !== "granted")
Notification.requestPermission();
});
function notifyMe() {
if (Notification.permission !== "granted")
Notification.requestPermission();
else {
var notification = new Notification('DIAZERO SECURITY', {
icon: '<?php url(); ?>/favicon.png',
body: "Sua solicitação foi atualizada!",
});
notification.onclick = function () {
window.open("<?php url(); ?>/solicitacao/<?php echo $a; ?>");
};
}
}
</script>