How to open page in the same tab with JavaScript?

0

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>
    
asked by anonymous 18.05.2017 / 19:50

1 answer

1

Use window.location.href instead of window.open :

window.location.href = "<?php url(); ?>/solicitacao/<?php echo $a; ?>";
    
18.05.2017 / 20:19