HTTP/2 302
x-cloud-trace-context: 348b033f6ed2fed69ba6e9eae5287272
location: /en-US/docs/Web/API/Notification/requestPermission
via: 1.1 google, 1.1 varnish, 1.1 varnish, 1.1 varnish, 1.1 varnish
accept-ranges: bytes
cache-control: no-store
server: Google Frontend
content-type: text/plain; charset=utf-8
date: Sat, 27 Dec 2025 22:47:04 GMT
x-served-by: cache-bfi-krnt7300039-BFI, cache-bfi-krnt7300054-BFI, cache-sin-wsss1830095-SIN, cache-bom-vanm7210064-BOM
x-cache: MISS, MISS, MISS, MISS
x-cache-hits: 0, 0, 0, 0
x-timer: S1766875624.003275,VS0,VE408
vary: Accept
content-length: 72
HTTP/2 301
via: 1.1 google, 1.1 varnish, 1.1 varnish, 1.1 varnish, 1.1 varnish
x-cloud-trace-context: c439f6010d5dc9376c0cf7f63d4ab76b
server: Google Frontend
location: /en-US/docs/Web/API/Notification/requestPermission_static
cache-control: max-age=2592000,public
content-type: text/plain; charset=utf-8
accept-ranges: bytes
age: 1460781
date: Sat, 27 Dec 2025 22:47:04 GMT
x-served-by: cache-bfi-krnt7300096-BFI, cache-bfi-krnt7300098-BFI, cache-sin-wsat1880098-SIN, cache-bom-vanm7210064-BOM
x-cache: MISS, HIT, HIT, HIT
x-cache-hits: 0, 4, 5, 0
x-timer: S1766875624.430326,VS0,VE1
vary: Accept
content-length: 91
HTTP/2 200
x-goog-stored-content-length: 147878
x-goog-metageneration: 1
referrer-policy: strict-origin-when-cross-origin
expires: Sat, 27 Dec 2025 21:59:13 GMT
x-goog-hash: crc32c=l9B92g==, md5=LLgf2SNGWhiO9aah/BNRaQ==
content-security-policy: default-src 'self'; script-src 'report-sample' 'self' 'wasm-unsafe-eval' https://www.google-analytics.com/analytics.js https://*.googletagmanager.com assets.codepen.io production-assets.codepen.io https://js.stripe.com 'sha256-XNBp89FG76amD8BqrJzyflxOF9PaWPqPqvJfKZPCv7M=' 'sha256-YCNoU9DNiinACbd8n6UPyB/8vj0kXvhkOni9/06SuYw=' 'sha256-PZjP7OR6mBEtnvXIZfCZ5PuOlxoDF1LDZL8aj8c42rw='; script-src-elem 'report-sample' 'self' 'wasm-unsafe-eval' https://www.google-analytics.com/analytics.js https://*.googletagmanager.com assets.codepen.io production-assets.codepen.io https://js.stripe.com 'sha256-XNBp89FG76amD8BqrJzyflxOF9PaWPqPqvJfKZPCv7M=' 'sha256-YCNoU9DNiinACbd8n6UPyB/8vj0kXvhkOni9/06SuYw=' 'sha256-PZjP7OR6mBEtnvXIZfCZ5PuOlxoDF1LDZL8aj8c42rw='; style-src 'report-sample' 'self' 'unsafe-inline'; object-src 'none'; base-uri 'self'; connect-src 'self' developer.allizom.org bcd.developer.allizom.org bcd.developer.mozilla.org updates.developer.allizom.org updates.developer.mozilla.org https://*.google-analytics.com https://*.analytics.google.com https://*.googletagmanager.com https://incoming.telemetry.mozilla.org https://observatory-api.mdn.allizom.net https://observatory-api.mdn.mozilla.net https://api.github.com/search/issues stats.g.doubleclick.net https://api.stripe.com; font-src 'self'; frame-src 'self' mdn.github.io *.mdnplay.dev *.mdnyalp.dev *.play.test.mdn.allizom.net https://v2.scrimba.com https://scrimba.com jsfiddle.net www.youtube-nocookie.com codepen.io survey.alchemer.com https://js.stripe.com; img-src 'self' data: *.githubusercontent.com *.googleusercontent.com *.gravatar.com mozillausercontent.com firefoxusercontent.com profile.stage.mozaws.net profile.accounts.firefox.com developer.mozilla.org mdn.dev wikipedia.org upload.wikimedia.org https://mdn.github.io/shared-assets/ https://mdn.dev/ https://*.google-analytics.com https://*.googletagmanager.com www.gstatic.com; manifest-src 'self'; media-src 'self' archive.org videos.cdn.mozilla.net https://mdn.github.io/shared-assets/; child-src 'self'; worker-src 'self';
x-goog-meta-goog-reserved-file-mtime: 1766796251
x-frame-options: DENY
x-goog-stored-content-encoding: identity
x-goog-generation: 1766797539338193
via: 1.1 google, 1.1 varnish, 1.1 varnish, 1.1 varnish, 1.1 varnish
server: Google Frontend
origin-trial: AxVILwizhbMjxFeHOn1P3R8niO1RJY/smaK4B4d1rLzc1gTaxtXMSaTi+FoigYgCw40uFRDwFcEAeqDR+vVLOW4AAABfeyJvcmlnaW4iOiJodHRwczovL2RldmVsb3Blci5tb3ppbGxhLm9yZyIsImZlYXR1cmUiOiJQcml2YXRlQXR0cmlidXRpb25WMiIsImV4cGlyeSI6MTc0MjA3OTYwMH0=
last-modified: Sat, 27 Dec 2025 01:05:39 GMT
x-goog-storage-class: STANDARD
x-cloud-trace-context: 9941201924cbb1d1857a1118100e8505
x-content-type-options: nosniff
content-type: text/html
etag: "2cb81fd923465a188ef5a6a1fc135169"
cache-control: public, max-age=3600
x-guploader-uploadid: AHVrFxO_jPD94xLCHgq0eixLge45E1JBfo4bLPZIpd117Fclsgp3s_AxDbGe52wDD1dLmNRM17Cp92A
strict-transport-security: max-age=63072000
content-encoding: gzip
accept-ranges: bytes
age: 0
date: Sat, 27 Dec 2025 22:47:04 GMT
x-served-by: cache-bfi-kbfi7400043-BFI, cache-bfi-kbfi7400043-BFI, cache-sin-wsss1830070-SIN, cache-bom-vanm7210064-BOM
x-cache: MISS, MISS, HIT, MISS
x-cache-hits: 0, 0, 0, 0
x-timer: S1766875624.449972,VS0,VE445
vary: Accept-Encoding
content-length: 20215
Notification: requestPermission() static method - Web APIs | MDN
Notification.requestPermission()
// Deprecated syntax using a callback
Notification.requestPermission(callback)
callback Optional
Deprecated
An optional callback function that is called with the permission value.
Deprecated in favor of the Promise return value.
A Promise that resolves to a string with the permission picked by the user.
Possible values for this string are:
granted
The user has explicitly granted permission for the current origin to display system notifications.
denied
The user has explicitly denied permission for the current origin to display system notifications.
default
The user decision is unknown; in this case the application will act as if permission was denied.
The deprecated version of the method returns undefined.
Assume this basic HTML:
<button>Notify me!</button>
It's possible to send a notification as follows — here we present a fairly verbose and complete set of code you could use if you wanted to first check whether notifications are supported, then check if permission has been granted for the current origin to send notifications, then request permission if required, before then sending a notification.
Note that the request should be made in response to user interaction: below, the method is called in the click event handler.
document.querySelector("button").addEventListener("click", notifyMe);
function notifyMe() {
if (!("Notification" in window)) {
// Check if the browser supports notifications
alert("This browser does not support desktop notification");
} else if (Notification.permission === "granted") {
// Check whether notification permissions have already been granted;
// if so, create a notification
const notification = new Notification("Hi there!");
// …
} else if (Notification.permission !== "denied") {
// We need to ask the user for permission
Notification.requestPermission().then((permission) => {
// If the user accepts, let's create a notification
if (permission === "granted") {
const notification = new Notification("Hi there!");
// …
}
});
}
// At last, if the user has denied notifications, and you
// want to be respectful there is no need to bother them anymore.
}
We no longer show a live sample on this page, as Chrome and Firefox no longer allow notification permissions to be requested from cross-origin <iframe> s, with other browsers to follow. To see an example in action, check out our To-do list example (also see the app running live ).
Enable JavaScript to view this browser compatibility table.