Illustration of a push notification permission prompt blocked inside an iframe embedded in a browser window Illustration of a push notification permission prompt blocked inside an iframe embedded in a browser window

Can You Ask for Push Notification Permission Inside an Iframe?

Why browsers block the push notification permission prompt in cross-origin iframes, what error you see, and three workarounds that work.

No, you can’t ask for push notification permission inside a cross-origin iframe. Chrome, Firefox and Safari all block Notification.requestPermission() and push subscription prompts from iframes on a different origin. Same-origin iframes can still prompt, but the permission belongs to the top-level site, so the reliable fix is to prompt on your own page or a subscription page.

This question comes up a lot with embedded widgets, landing page builders and chat tools. Someone drops a “Get notifications” button into an iframe, nothing happens, and the console shows an error. Here’s why the push notification permission iframe rule exists, what each browser does, and the workarounds that actually work.

Key facts at a glance:

  • Firefox: blocked permission requests from cross-origin iframes in Firefox 70, according to Mozilla bug 1560741.
  • Chrome: announced the same block earlier, and MDN notes that Chrome and Firefox no longer allow these requests from cross-origin iframes.
  • Safari: WebKit rejects the request with “Cannot request permission from cross-origin iframe”, as shown in WebKit changeset 291737.
  • No opt-in: there’s no Permissions Policy “allow” attribute that re-enables notifications for an iframe.

Can you ask for push notification permission inside an iframe?

You can’t ask for push notification permission inside a cross-origin iframe in any major browser. If the iframe’s origin differs from the page’s address bar origin, the request is rejected or ignored without showing a prompt.

A same-origin iframe is different. If yoursite.com embeds a page from yoursite.com, the request comes from the same origin as the top-level page. In that case the browser can show the prompt, and the permission applies to yoursite.com.

SetupExampleCan it show the prompt?
Top-level pageyoursite.com/blogYes, after a user gesture
Same-origin iframeyoursite.com embeds yoursite.com/widgetGenerally yes; the permission belongs to yoursite.com
Cross-origin iframeyoursite.com embeds widget.vendor.comNo, blocked
Subdomain iframeyoursite.com embeds news.yoursite.comNo, a subdomain is a different origin

The subdomain row surprises people. Origins compare scheme, host and port, so news.yoursite.com isn’t the same origin as yoursite.com. My post on why web push subscriptions are tied to a domain explains this in more detail.

Why do browsers block prompts in iframes?

Browsers block them because the prompt names the site in the address bar. If an embedded vendor could ask, users would think they were allowing the main site, while the vendor actually got the permission.

Mozilla’s discussion in the bug above makes this point. A page would rarely want an embedded third party to send notifications in its name. And if the permission belonged to the iframe’s origin, the prompt would show a site the user never visited. Neither outcome is clear to users, so browsers simply say no.

There’s also an abuse history behind it. Ad scripts in iframes once used notification prompts aggressively. Blocking them in cross-origin frames removed a big source of spam prompts.

What error do you see when it fails?

You’ll see a rejected promise, a “denied” result or a console warning, depending on the browser. In every case, no prompt appears, and the user never gets a choice.

  • Safari: NotAllowedError with the message “Cannot request permission from cross-origin iframe”.
  • Firefox: the request is denied without a prompt.
  • Chrome: the request is denied, with a console message about cross-origin iframes.

Because the result can look like “denied”, don’t store it as a real user decision. The user never saw anything. If you save it as a refusal, you may hide the subscribe option for good.

How do you collect push subscribers from embedded content?

Move the prompt out of the iframe and onto a top-level page of the origin that will send the notifications. There are three practical ways to do this.

1. Prompt on the parent page

If you own both pages, let the iframe send a message to the parent with window.postMessage(). The parent page then shows its own button and calls Notification.requestPermission() after the click.

// inside the iframe
parent.postMessage({ type: 'subscribe-click' }, 'https://yoursite.com');

// on the parent page
window.addEventListener('message', (e) => {
  if (e.origin !== 'https://widget.yoursite.com') return;
  if (e.data.type === 'subscribe-click') showSubscribeButton();
});

Note that the parent should show a real button rather than calling the prompt straight from the message. Browsers require a recent user gesture on the page that asks.

2. Open a subscription page in a new tab or popup

When you can’t change the parent page, link to a page on your own domain. For example, the iframe button opens yoursite.com/subscribe in a new tab. That page is top-level, so it can ask normally.

3. Use a shareable subscription link

Some push tools give you a link that opens a subscription page on your domain. You can put it in emails, social posts, video descriptions or embedded widgets. LaraPush calls these shareable subscription links, and its Premium Add-on adds subscriber collection from external links, which I cover in my guide to collecting subscribers from an external link.

Does this affect AMP pages and in-app browsers?

Yes, and both have their own workarounds. AMP pages and in-app browsers are two common places where the prompt seems “broken”.

AMP pages are often served from a Google cache, which is a different origin. The amp-web-push component handles this by opening a helper page on your own origin to ask for permission. My post on AMP push notifications explains the flow.

In-app browsers, like the ones inside social apps, often don’t support web push at all. I’ve covered those in web push in in-app browsers.

What’s the best way to ask for permission?

The best way is a clear button on your own top-level page, shown after the visitor has a reason to say yes. This works in every browser, respects the gesture rules, and usually gets better opt-in rates than an instant prompt.

  1. Show a soft prompt or bell icon that explains what people will get.
  2. Call Notification.requestPermission() only after a click on that element.
  3. Subscribe with pushManager.subscribe() once permission is granted.
  4. Save the subscription to your server, tied to your origin.

For prompt timing and wording, see my push permission prompt best practices. If the prompt doesn’t appear at all, check why the push permission prompt stopped appearing.

Where LaraPush fits

LaraPush is a self-hosted web push panel that runs on your own VPS, with a one-time licence from $499 (check LaraPush pricing). It offers several prompt types, including native, modal, full screen and bell, plus delay and re-prompt controls, all listed on the features page. The script runs on your own pages, so prompts come from your origin, not from an iframe. The trade-offs are no free plan and a server you maintain. For setup steps, see the LaraPush guide.

Frequently asked questions

Can a Permissions Policy allow notifications in an iframe?

No. Unlike the camera or microphone, notifications have no Permissions Policy feature that an embedding page can grant to an iframe. Browsers deliberately block cross-origin iframes from asking, so the allow attribute on the iframe tag won’t change anything.

Can a cross-origin iframe subscribe to push if the user already allowed notifications?

Don’t rely on it. Permission and push subscriptions are tied to an origin, and the iframe’s origin is not the site in the address bar. Browsers also partition storage for third-party frames. Subscribe users on a top-level page of the origin that will send the notifications.

Does a subdomain iframe count as cross-origin?

Yes. An origin is the scheme, host and port together, so news.example.com and example.com are different origins. A prompt inside an iframe from news.example.com, embedded on example.com, will be blocked like any other cross-origin frame.

Can an embedded chat widget offer push notifications?

Only by sending the user to a top-level page. The widget can open a subscription page on its own domain in a new tab, or ask the parent site to show a button. Notifications then come from the domain that asked, which the user sees in the prompt.

Will the blocked request count as a user denying notifications?

It may look like it, because some browsers return denied. However, the user never saw a prompt, so the site’s real permission is unchanged. Don’t store that result as a refusal, or you might hide your subscribe button from people who would say yes.

Leave a Reply

Your email address will not be published. Required fields are marked *