1

PopUp Notification

Hello everyone,

I need popup notification like facebook notification in above image for first time on opening the site on browser and once it allow I will store in cookie for future use. I am thinking in core javascript to built this but unable to achieve it.

Any help will be great.

Thanks in advance.

Sikander
  • 654
  • 1
  • 7
  • 21

3 Answers3

6

Use browser's Notification Api.

Notification.requestPermission().then(function(result) {
   console.log(result);
});

https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API/Using_the_Notifications_API

jaguwalapratik
  • 406
  • 2
  • 10
-1

use this

window.confirm("your warning text here")

on page load function you can write this

var x =window.confirm("your warning text here")

If user selects ok value of x will be true and on cancel it will be false based on this value you can write your logic

Or you can use this link may be helpful

Desktop notifications allowing not working on chrome

Community
  • 1
  • 1
Vicky Kumar
  • 1,358
  • 1
  • 14
  • 26
-1

You can do it with confirm()

var x = confirm("Notification!");
    if (x == true) {
        alert("OK");
    }
    else {
        alert("Cancel");
    }
Sanzeeb Aryal
  • 4,358
  • 3
  • 20
  • 43