Webkit notifications requestPermission function doesn't work Webkit notifications requestPermission function doesn't work google-chrome google-chrome

Webkit notifications requestPermission function doesn't work


Check the specification at chromium api docs. You can call it only as a feedback to user gesture/action - mouse click etc.

requestPermission Requests that the user agent ask the user for permission to show notifications from scripts. This method should only be called while handling a user gesture; in other circumstances it will have no effect. This method is asynchronous. The function provided in callback will be invoked when the user has responded to the permission request. If the current permission level is PERMISSION_DENIED, the user agent may take no action in response to requestPermission.

UPDATE 2014-10-01: In Chrome 37, the user gesture requirement was removed. It should now be possible to request permission to display notifications at any moment. If you wish to target older versions of Chrome as well (eg. in a corporate environment), you'll probably need to continue relying on user gesture events.


For checking Notification on local file (file://) permission will popup but notification wont work on chrome.

As a work around you can change

Content setting > Notification > Allow All websites to show notification

Shortest code to show notification

var notification = new Notification("YOUR MESSAGE");