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

228
Vistas
Using Notifications API in an IFrame [chrome, javascript]

I'm trying to write a plugin for a website, the website always loads this plugin as an iframe. I would like to send browser notifications to the user, using this api: https://developer.mozilla.org/en-US/docs/Web/API/Notification/requestPermission Only problem is the API doesn't seem to support asking permission from an iframe.

Is there any way I can make this work? I also tried this solution: How subscribe pushManager via iframe in Chrome?)

"The only alternative (that we have used for Pushpad Express for example) is to redirect to open a new window from the iframe, then ask permission from the top level window and finally redirect back." and asking the permission from there, but it never asks me for permission, so the value stays denied.

Unfortunately that also doesn't seem to work for me, I open a new windows and ask for permission but it also just never shows the request.

Does anybody have some other ideas?

Edit 1:

I am trying to do it this way now:, it opens a new window but still no luck with asking the permission:

function openAndPush() {
    var win = window.open("", "", "width=400,height=400");
    win.test = function () {
        askNotificationPermission();
    }
    win.test();
    setTimeout(function () {
        win.document.body.appendChild(element);
        console.log('New script appended!')
    }, 10000);
}

Edit 2: Got the code working by asking permission in a new window, it executes this piece of code:

if (Notification.permission === "granted") {
        console.log("[App] @!@@!!@!@!@!@!@!@!@")
        var notification = new Notification("Hi there!");
    }

Which means permissions are granted, but I'm still not seeing a desktop notification. Website is https, chrome settings checked, and no errors. Anybody got a suggestion?

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