{"id":148175,"date":"2018-10-22T04:50:33","date_gmt":"2018-10-22T04:50:33","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=148175"},"modified":"2021-07-16T14:07:31","modified_gmt":"2021-07-16T14:07:31","slug":"desktop-notification-by-javascript-jquery","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/","title":{"rendered":"Desktop Notification by Javascript\/Jquery"},"content":{"rendered":"\n<p><strong>Desktop Notification by Javascript\/Jquery&nbsp; &nbsp;&#8211;&nbsp;<\/strong><\/p>\n\n\n\n<p>This is used to notify users outside the context of a web page. When we need show some real-time&nbsp; information displaying to notifications on the Desktop, it generally refers to some static display area outside the web page, but that may take several forms, including:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>The area to Display users notification.<\/li><li>An area within the chrome of the user agent.<\/li><li>The home screen of a mobile device(For mobile user).<\/li><\/ul>\n\n\n\n<p><strong>Notification Constructor &#8211;<\/strong><\/p>\n\n\n\n<p>Notification() constructor creates a new notification() object instance for represent user notification.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted brush:js\">var myNotify = new Notification(title, options);<\/pre>\n\n\n\n<p id=\"Constructor\">&nbsp; title &#8211; Title of Notification<\/p>\n\n\n\n<p>&nbsp;options -Any custom settings that you want to apply to the notification message example-<\/p>\n\n\n\n<pre class=\"wp-block-preformatted brush:js\">var options = {\n                body: 'Test notification message.', \/\/ body part of the notification\n                dir: 'ltr', \/\/ use for derection of message\n                image:'download.png' \/\/ use for show image\n\n              }\n\n  var n = new Notification('Title', options);\n\nNote: It does not work on IP and Non-secure server(http), It work secure server(https) only.\n\n<\/pre>\n\n\n\n<p>Now we implement in the example &#8212;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted brush:js\">function showNotification() {\n  \t\t\tif(window.Notification) {\n  \t\t\t\tNotification.requestPermission(function(status) {\n  \t\t\t\t\tconsole.log('Status: ', status); \/\/ show notification permission if permission granted then show otherwise message will not show\n              var options = {\n                  body: 'Test notification message.', \/\/ body part of the notification\n                  dir: 'ltr', \/\/ use for direction of message\n                  image:'download.png' \/\/ use for show image\n\n                }\n\n    \t\t\t\t\tvar n = new Notification('Title', options);\n  \t\t\t\t});\n  \t\t\t}\n  \t\t\telse {\n  \t\t\t\talert('Your browser doesn\\'t support notifications.');\n  \t\t\t}\n  \t\t}<\/pre>\n\n\n\n<p>Output &#8212;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"1298\" height=\"673\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/10\/image.png\" alt=\"\" class=\"wp-image-148382\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/10\/image.png 1298w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/10\/image-250x130.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/10\/image-300x156.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/10\/image-768x398.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/10\/image-1200x622.png 1200w\" sizes=\"(max-width: 1298px) 100vw, 1298px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>In case you have any Query then feel free to ask in the comment section below. Happy coding!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Desktop Notification by Javascript\/Jquery&nbsp; &nbsp;&#8211;&nbsp; This is used to notify users outside the context of a web page. When we need show some real-time&nbsp; information displaying to notifications on the Desktop, it generally refers to some static display area outside the web page, but that may take several forms, including: The area to Display users <a href=\"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":223,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[305],"tags":[],"class_list":["post-148175","post","type-post","status-publish","format-standard","hentry","category-opencart"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Desktop Notification by Javascript\/Jquery - Webkul Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Desktop Notification by Javascript\/Jquery - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"Desktop Notification by Javascript\/Jquery&nbsp; &nbsp;&#8211;&nbsp; This is used to notify users outside the context of a web page. When we need show some real-time&nbsp; information displaying to notifications on the Desktop, it generally refers to some static display area outside the web page, but that may take several forms, including: The area to Display users [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-10-22T04:50:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-07-16T14:07:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/10\/image.png\" \/>\n<meta name=\"author\" content=\"Dilip Kumar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dilip Kumar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/\"},\"author\":{\"name\":\"Dilip Kumar\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/ba9ea4b96b34b29ead411f909bec1de8\"},\"headline\":\"Desktop Notification by Javascript\/Jquery\",\"datePublished\":\"2018-10-22T04:50:33+00:00\",\"dateModified\":\"2021-07-16T14:07:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/\"},\"wordCount\":148,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/10\/image.png\",\"articleSection\":[\"opencart\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/\",\"url\":\"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/\",\"name\":\"Desktop Notification by Javascript\/Jquery - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/10\/image.png\",\"datePublished\":\"2018-10-22T04:50:33+00:00\",\"dateModified\":\"2021-07-16T14:07:31+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/10\/image.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/10\/image.png\",\"width\":1298,\"height\":673},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Desktop Notification by Javascript\/Jquery\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/ba9ea4b96b34b29ead411f909bec1de8\",\"name\":\"Dilip Kumar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d2f01d36e5ba04a7c5574295c661a96d202dd4fc55accdcba5972ece1ce93479?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d2f01d36e5ba04a7c5574295c661a96d202dd4fc55accdcba5972ece1ce93479?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Dilip Kumar\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/dilipkumar-oc571\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Desktop Notification by Javascript\/Jquery - Webkul Blog","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:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/","og_locale":"en_US","og_type":"article","og_title":"Desktop Notification by Javascript\/Jquery - Webkul Blog","og_description":"Desktop Notification by Javascript\/Jquery&nbsp; &nbsp;&#8211;&nbsp; This is used to notify users outside the context of a web page. When we need show some real-time&nbsp; information displaying to notifications on the Desktop, it generally refers to some static display area outside the web page, but that may take several forms, including: The area to Display users [...]","og_url":"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2018-10-22T04:50:33+00:00","article_modified_time":"2021-07-16T14:07:31+00:00","og_image":[{"url":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/10\/image.png","type":"","width":"","height":""}],"author":"Dilip Kumar","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Dilip Kumar","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/"},"author":{"name":"Dilip Kumar","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/ba9ea4b96b34b29ead411f909bec1de8"},"headline":"Desktop Notification by Javascript\/Jquery","datePublished":"2018-10-22T04:50:33+00:00","dateModified":"2021-07-16T14:07:31+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/"},"wordCount":148,"commentCount":2,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/10\/image.png","articleSection":["opencart"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/","url":"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/","name":"Desktop Notification by Javascript\/Jquery - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2018\/10\/image.png","datePublished":"2018-10-22T04:50:33+00:00","dateModified":"2021-07-16T14:07:31+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/10\/image.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2018\/10\/image.png","width":1298,"height":673},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/desktop-notification-by-javascript-jquery\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Desktop Notification by Javascript\/Jquery"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/ba9ea4b96b34b29ead411f909bec1de8","name":"Dilip Kumar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d2f01d36e5ba04a7c5574295c661a96d202dd4fc55accdcba5972ece1ce93479?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d2f01d36e5ba04a7c5574295c661a96d202dd4fc55accdcba5972ece1ce93479?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Dilip Kumar"},"url":"https:\/\/webkul.com\/blog\/author\/dilipkumar-oc571\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/148175","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/223"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=148175"}],"version-history":[{"count":15,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/148175\/revisions"}],"predecessor-version":[{"id":296700,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/148175\/revisions\/296700"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=148175"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=148175"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=148175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}