Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

135
Vistas
How to Bring Desktop Browser Back to Forefront When Minimized through a Push Notification

I'm trying to bring desktop browsers such as Firefox, Chrome, Brave, etc to the forefront when a push notification is clicked.

EDIT: As soon as I posted this comment I thought of removing event.preventDefault(); and that worked to do the popup, but it opens in a new tab and doesn't get selected.

As it stands with this code, the page opens but it opens in a new tab that is not selected. Let's say I minimize Firefox and start working in notepad or GIMP; I want to click a push notification then have it bring the browser back to forefront with the new tab selected aswell.

Jquery or Javascript will work if I can accomplish my objective.

Also, I don't want this to open a new browser instance; I want the code to use the existing browser instance but pop forward with my selected link.

Here's my code so far, and it doesn't accomplish my goal:

function sendPush(pushTitle, pushBody, pushUrl) {
    
    // pushTitle is the title, pushBody is the body, pushUrl is the link that will be opened when the push notification is clicked

    // check if the browser supports push notes
    if (!("Notification" in window)) {
      console.log("This browser does not support desktop notification. To get push notifications use a chromium based browser or mozilla based browser");
    }
    
    // generate and send the push notification
    else if (Notification.permission === "granted") {
      var notification = new Notification(pushTitle,{ 
        onshow: null, 
        onerror: null, 
        onclose: null, 
        title: pushTitle, 
        dir: "auto", 
        lang: "", 
        body: pushBody, 
        tag: "", 
        icon: pushIcon });
    }
    
    // add the onclick listener to make the notification interactive and open a link
    if (notification){
        notification.onclick = function(event) { 
            // if I remove this it works but doesn't select the new tab
            //event.preventDefault(); 
            // I tried removing _blank and that didn't work
            window.open(pushUrl, '_blank');
            // I tried doing window.focus() but it doesn't work
            window.focus();
        }
    }
}

How can I bring the browser window back to forefront if it's in the background from a push notification?

I have searched on google and duckduckgo extensively but not found anything that works. Is this even possible?

EDIT: if I remove event.preventDefault(); it brings the window to forefront but the tab is not selected when the window pops up. Any way to open a new tab AND pop up at the same time?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda