Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

230
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!