Skip to main content

Push Notification to the browser with Javascript

Push notification to the browser is a way to send an information message to the browser same like you experiencing in mobile Apps like Facebook or Whatsapp.

You can do so using a simple jQuery and Javascript code, Today we will only cover the Javscript part in this tutorial.

Try Demo

Ask User for notification permission

First of all we need to request for the permission to user to allow browser notification.



Initialize the notification object

If user have granted for notification, we need to initialize the notification object where we need to pass few parameters

Callback functions

You can add call back function on notification. Notification have onclick and close callback events you can use it as below. For demo I have just open the url onclick and onclose just print a log in console.


Wrapping all together

Try Demo


At the movement browser push notification will only supported in latest Chrome and Firefox.

Hardik Joshi

Hardik Joshi is Founder, Developer and Writer at, He loves to write usable code for the Web and other digital sources.