{"id":15904,"date":"2017-01-30T16:15:18","date_gmt":"2017-01-30T14:15:18","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=15904"},"modified":"2017-12-19T13:25:26","modified_gmt":"2017-12-19T11:25:26","slug":"html5-notification-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/","title":{"rendered":"HTML5 Notification Example"},"content":{"rendered":"<p>In this example we are going to learn about HTML5 notification API.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n[ulp id=&#8217;tgm4cmEWcKUikZNn&#8217;]<br \/>\n&nbsp;<br \/>\nFor this example we will use:<\/p>\n<ul>\n<li>A computer with a modern browser installed.<\/li>\n<li>notepad++.<\/li>\n<li>Wamp Server: You can actually use any server, the most important thing is that your app has to be hosted on an http server or else HTML5 notifications will not work.<\/li>\n<\/ul>\n<h2>1. Getting Started<\/h2>\n<p>HTML5 notification API provides a way to notify or alert users outside the context of a webpage. HTML5 notification API is displayed at the system level. This means the way notification are displayed depends on the computer or device OS(operating system), just imagine the way desktop computers or mobile devices display notification. An HTML5 notification may appear in any of the following places:<\/p>\n<ul>\n<li>A corner of the user&#8217;s display.<\/li>\n<li>An area within the chrome of the user agent.<\/li>\n<li>The &#8220;home&#8221; screen of a mobile device.<\/li>\n<\/ul>\n<p>Some of the important applications of this technology is in web based email systems or internet relay chat (IRC), where there is a need to notify users about new messages that has arrived (when the user is currently not using the browser application)<\/p>\n<h3>1.1 The Notification Object<\/h3>\n<p>We can create a new notification by creating an instance of the <code>Notification<\/code> object. Let&#8217;s see how to do this below:<\/p>\n<pre class=\"brush:bash\">var title=\"New Notification\";\/\/ title for the notification\r\nvar options ={\r\nbody:\"this is a new notification\",\r\nicon:\"pathtoicon\/icon.jpg\"\/\/icon to display and it is optional\r\n}\r\nnoti= new Notification(title, options);\/\/instatiate the notification object.\r\n\r\n<\/pre>\n<h3>1.2 Notification Permission<\/h3>\n<p>Before a webpage can send notifications it needs to be granted permission to do so. The user needs to grant the application permission at least once. The permission\u00a0to display\u00a0notification\u00a0for a given\u00a0origin\u00a0can be one of three strings:<\/p>\n<ul>\n<li>default: This is equivalent to &#8220;denied&#8221;, but the user has made no explicit choice thus far.<\/li>\n<li>denied: This means the user does not want\u00a0notifications.<\/li>\n<li>granted: This means\u00a0notifications\u00a0can be displayed.<\/li>\n<\/ul>\n<p>You can check to see if you have permission by checking the value of the<code> Notification.permission <\/code>read only property.<\/p>\n<pre class=\"brush:bash\">Notification.requestPermission();\/\/it takes a callback function \r\n\r\n<\/pre>\n<p>Commonly, you&#8217;ll ask for permission to display notifications when your app is first initialized, and before trying to instantiate a Notification object.<br \/>\nLets see a full example below.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>noti.html<\/em><\/span><\/p>\n<pre class=\"brush:html\">&lt;!DOCTYPE html&gt; \r\n&lt;html lang=en&gt;\r\n\t&lt;head&gt;\r\n\t&lt;style&gt;\r\n\thtml, body{\r\n\twidth:100%;\r\n\theight:100%;\r\n\tmargin:0%;\r\n\tfont-family:\"helvetica\",\"verdana\",\"calibri\", \"san serif\";\r\n\toverflow:visible;\r\n\tpadding:0%;\r\n\tborder:0%;\r\n\t}\r\n\t \r\n\t&lt;\/style&gt;\r\n\t \t\t&lt;meta charset=\"utf-8\" \/&gt;\r\n\t\t&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi\"\/&gt;\r\n\t\r\n\t&lt;title&gt; \r\nHtml5 Notification API Example\r\n&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n\t&lt;body &gt;\r\n\t&lt;script&gt;\r\n\twindow.addEventListener(\"load\",c);\/\/ register an eventlistener for web page onload\r\n\tfunction init(){\r\n\tvar b=document.getElementById(\"but\");\/\/get the button object\r\n\tb.addEventListener(\"click\",noti,false);\/\/register an eventlistener for when user clicks the button\r\n\t}\r\n\t\/\/ function called when the web page has loaded\r\n\tfunction c(){\r\n\tinit();\r\n\tif(window.Notification &amp;&amp; Notification.permission!==\"granted\"){\/\/check to see if notification is granted and notification is supported\r\n\t\/\/if it is not supported request permission\r\n\tNotification.requestPermission(function(status){\r\n\tif(Notification.permission!==status){\r\n\tNotification.permission=status;\r\n\t}\r\n\t})\r\n\t}\r\n\t}\r\n\t\/\/function called when button is clicked and shows notification\r\n\tfunction noti(){\r\n\tif(Notification.permission==\"granted\"){\/\/check if we have notification permission\r\n\tvar title=\"Just Testing This App\";\/\/title for notification\r\n\tvar options={\/\/options for notification\r\n\tbody:\"it is just a test\"\r\n\t\r\n\t}\r\n noti= new Notification(title,options);\/\/permission is granted, display notification\r\n  \r\n }\r\n else{\r\n alert(\"permission not granted\");\/\/alert error message : permission is not granted\r\n }\r\n\r\n\r\n}\r\n\t&lt;\/script&gt;\r\n\t&lt;button id=but&gt;\r\n\tSend Notification Now\r\n\t&lt;\/button&gt;\r\n\t&lt;\/body&gt;\r\n\t&lt;\/html&gt;\r\n<\/pre>\n<p><b>Note: <\/b>inline JavaScript should be avoided because it makes the markup bigger and less readable. The content, structure and behavior are not well-separated, thus making a bug harder to find. Furthermore, usage of event attributes almost always causes scripts to expose global functions on the\u00a0Window\u00a0object, thus polluting the global namespace.<br \/>\nIn line 25 we register a web page onload event, which fires our function <code>c()<\/code> when the web page is done loading. In line 32, inside the function <code>c<\/code> we call the function <code>init<\/code>. The <code>init<\/code> function simply registers an onclick event listener for our button.<\/p>\n<p>In line 32 (through an IF statement) we check if the browser running the code supports HTML5 notification. in that same line we check if the user has given the webpage notification permission. If the first condition returns true and the second condition returns false, we ask the user for notification permission(this is usually shown as dialog box with a message at the top and a yes and no button below.). If the &#8220;show me notification&#8221; button is clicked the <code>noti<\/code> function is called. The function checks if the web page has permission for notification, if it has permission we show a notification else alert the user about the error.<\/p>\n<h3>1.3 Notification Events<\/h3>\n<p>Events can be fired on a notification instance. Developers can use these events to generate the required behavior.<\/p>\n<ul>\n<li>click: This event is triggered when a user clicks the notification.<\/li>\n<li>error: This event is triggered, when for some reasons the notification cannot be displayed.<\/li>\n<\/ul>\n<p>These events can be tracked using the <code>onclick\u00a0<\/code>and <code>onerror<\/code> handlers. You can also use the <code>addEvenlistener<\/code> method on it.<\/p>\n<h3>1.4 Properties Of The Notification Object<\/h3>\n<ul>\n<li>Notification.permission: It is a static property, this means it is only available on the notification Object and not its instance. It defines the current permission status and be either granted, denied or default.<\/li>\n<li>Notification.body: The body string of the notification as specified in the options parameter of the constructor.<\/li>\n<li>Notification.lang: The language code of the notification as specified in the options parameter of the constructor.<\/li>\n<li>Notification.tag: This represents the tag of the notification and it is declared or specified in the options parameter of the notification constructor.<\/li>\n<li>Notification.icon: This defines the URL of the image used as an icon of the notification as specified in the options parameter of the constructor.<\/li>\n<li>Notification.icon: This is the URL of an image to be displayed as part of the notification, as specified in the options parameter of the constructor.<\/li>\n<li>Notification.timestamp: This holds the time at which is created.<\/li>\n<li>Notification.title: This holds the title of the notification as specified in the first parameter of the constructor.<\/li>\n<\/ul>\n<p>Your app can become a nuisance if it sends a lot of notification to the user in a short time. To avoid spamming the user with too much notification, it is possible to add a tag to a new notification. If a notification already has the same tag and has not been displayed yet, the new notification replaces that previous notification. If the notification with the same tag has already\u00a0been\u00a0displayed, the previous notification is closed and the new one is displayed.<br \/>\nLets take a look at an example below<\/p>\n<p><span style=\"text-decoration: underline;\"><em>noti2.html<\/em><\/span><\/p>\n<pre class=\"brush:html\">&lt;!DOCTYPE html&gt; \r\n&lt;html lang=en&gt;\r\n\t&lt;head&gt;\r\n\t&lt;style&gt;\r\n\thtml, body{\r\n\twidth:100%;\r\n\theight:100%;\r\n\tmargin:0%;\r\n\tfont-family:\"helvetica\",\"verdana\",\"calibri\", \"san serif\";\r\n\toverflow:visible;\r\n\tpadding:0%;\r\n\tborder:0%;\r\n\t}\r\n\t \r\n\t&lt;\/style&gt;\r\n\t \t\t&lt;meta charset=\"utf-8\" \/&gt;\r\n\t\t&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi\"\/&gt;\r\n\t\r\n\t&lt;title&gt; \r\nHtml5 Notification API Example\r\n&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n\t&lt;body &gt;\r\n\t&lt;script&gt;\r\n\twindow.addEventListener(\"load\",c);\/\/ register an eventlistener for web page onload\r\n\tfunction init(){\r\n\tvar b=document.getElementById(\"but\");\/\/get the button object\r\n\tb.addEventListener(\"click\",noti,false);\/\/register an eventlistener for when user clicks the button\r\n\t}\r\n\t\/\/ function called when the web page has loaded\r\n\tfunction c(){\r\n\tinit();\r\n\tif(window.Notification &amp;&amp; Notification.permission!==\"granted\"){\/\/check to see if notification is granted and notification is supported\r\n\t\/\/if it is not supported request permission\r\n\tNotification.requestPermission(function(status){\r\n\tif(Notification.permission!==status){\r\n\tNotification.permission=status;\r\n\t}\r\n\t})\r\n\t}\r\n\t}\r\n\t\/\/function called when button is clicked and shows notification\r\n\tfunction noti(){\r\n\tif(Notification.permission==\"granted\"){\/\/check if we have notification permission\r\n\tvar title=\"Just Testing This App\";\/\/title for notification\r\n\tvar options={\/\/options for notification\r\n\tbody:\"it is just a test\",\r\n\ttag:\"notifications\"\r\n\t}\r\n\tvar i=0\/\/counter variable\r\n\t\/\/we generate a notification every 200 millisecond\r\n\tvar timer =setInterval(function(){\r\n\t noti= new Notification(title,options);\/\/permission is granted, display notification\r\n\t if(i&gt;7){\/\/if the counter is greater than seven\r\n\t clearInterval(timer);\/\/ clear the timer\r\n\t }\r\n\t i++;\r\n\t},200)\r\n\r\n  \r\n }\r\n else{\r\n alert(\"permission not granted\");\/\/alert error message : permission is not granted\r\n }\r\n\r\n\r\n}\r\n\t&lt;\/script&gt;\r\n\t&lt;button id=but&gt;\r\n\tSend Notification Now\r\n\t&lt;\/button&gt;\r\n\t&lt;\/body&gt;\r\n\t&lt;\/html&gt;\r\n<\/pre>\n<h2>2. Summary<\/h2>\n<p>In this example we learnt about HTML5 notifications. We learnt about HTML5 Notification object, its properties and methods. We also learnt how to use and work with this object.<\/p>\n<h2>3. Download the source code<\/h2>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <strong><strong><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/01\/html5notificationapi.zip\">html5notificationapi<\/a><\/strong><\/strong><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this example we are going to learn about HTML5 notification API. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [ulp id=&#8217;tgm4cmEWcKUikZNn&#8217;] &nbsp; For this example we will use: A computer with a modern browser installed. notepad++. Wamp Server: You can actually use any server, the most important thing is that &hellip;<\/p>\n","protected":false},"author":164,"featured_media":914,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[430],"class_list":["post-15904","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-html5","tag-notification-api"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>HTML5 Notification Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"In this example we are going to learn about HTML5 notification API. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"HTML5 Notification Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"In this example we are going to learn about HTML5 notification API. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2017-01-30T14:15:18+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-12-19T11:25:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Olayemi Odunayo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Olayemi Odunayo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/\"},\"author\":{\"name\":\"Olayemi Odunayo\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8\"},\"headline\":\"HTML5 Notification Example\",\"datePublished\":\"2017-01-30T14:15:18+00:00\",\"dateModified\":\"2017-12-19T11:25:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/\"},\"wordCount\":935,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"keywords\":[\"notification api\"],\"articleSection\":[\"HTML5\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/\",\"name\":\"HTML5 Notification Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"datePublished\":\"2017-01-30T14:15:18+00:00\",\"dateModified\":\"2017-12-19T11:25:26+00:00\",\"description\":\"In this example we are going to learn about HTML5 notification API. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"HTML5\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/html5\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"HTML5 Notification Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8\",\"name\":\"Olayemi Odunayo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g\",\"caption\":\"Olayemi Odunayo\"},\"description\":\"I am a programmer and web developer, who has experience in developing websites and writing desktop and mobile applications. I have worked with both schematic and schemaless databases. I am also familiar with third party API and working with cloud servers. I do programming on the client side with Java, JavaScript, html, Ajax and CSS while I use PHP for server side programming.\",\"sameAs\":[\"https:\/\/www.webcodegeeks.com\/\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/olayemi-odunayo\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"HTML5 Notification Example - Web Code Geeks - 2026","description":"In this example we are going to learn about HTML5 notification API. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/","og_locale":"en_US","og_type":"article","og_title":"HTML5 Notification Example - Web Code Geeks - 2026","og_description":"In this example we are going to learn about HTML5 notification API. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;","og_url":"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2017-01-30T14:15:18+00:00","article_modified_time":"2017-12-19T11:25:26+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","type":"image\/jpeg"}],"author":"Olayemi Odunayo","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Olayemi Odunayo","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/"},"author":{"name":"Olayemi Odunayo","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8"},"headline":"HTML5 Notification Example","datePublished":"2017-01-30T14:15:18+00:00","dateModified":"2017-12-19T11:25:26+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/"},"wordCount":935,"commentCount":1,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","keywords":["notification api"],"articleSection":["HTML5"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/","url":"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/","name":"HTML5 Notification Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","datePublished":"2017-01-30T14:15:18+00:00","dateModified":"2017-12-19T11:25:26+00:00","description":"In this example we are going to learn about HTML5 notification API. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-notification-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"HTML5","item":"https:\/\/www.webcodegeeks.com\/category\/html5\/"},{"@type":"ListItem","position":3,"name":"HTML5 Notification Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8","name":"Olayemi Odunayo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g","caption":"Olayemi Odunayo"},"description":"I am a programmer and web developer, who has experience in developing websites and writing desktop and mobile applications. I have worked with both schematic and schemaless databases. I am also familiar with third party API and working with cloud servers. I do programming on the client side with Java, JavaScript, html, Ajax and CSS while I use PHP for server side programming.","sameAs":["https:\/\/www.webcodegeeks.com\/"],"url":"https:\/\/www.webcodegeeks.com\/author\/olayemi-odunayo\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/15904","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/164"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=15904"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/15904\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/914"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=15904"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=15904"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=15904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}