D
D
Denis Black2018-07-06 15:28:52
Web development
Denis Black, 2018-07-06 15:28:52

Popup window with "Remind me later" button, how to do?

Hello everyone, please tell me how to implement a pop-up window / message with a "Remind me later" and "Close" button.
So that when you click the "Remind me later" button, you can set a timer after how long to play the message again.
And how to implement the ability to play a pop-up window regardless of where the user is on the site (on which page)?

Are there ready-made JS libraries?
View window:
5b3f5fd3ddc02546714467.png
Alert-Toast-MK-Web-Notifications

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ihor Bratukh, 2018-07-06
@BRAGA96

When the button is clicked, write to LocalStorage the time of pressing the timestamp. When refreshing the page, check if Date.now() > timestamp + 5000 (ваше время)true, then show the window.

if (localStorage.getItem('popup') !== null) {
  var timestamp = localStorage.getItem('popup');
  if (Date.now() > Number(timestamp) + 5000) { // 5 секунд
    // показываем окно
    $('.popup').fadeIn();
  }
}

$('button').on('click', function() {
  localStorage.setItem('popup', Date.now());
});

M
MonsterAndrew, 2018-07-06
@MonsterAndrew

Lay out the window, make buttons there, and set `setTimeout` after pressing "Remind me later".

So that when you click the "Remind me later" button, you can set a timer after how long to play the message again.
Just put a window code on each page.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question