Answer the question
In order to leave comments, you need to log in
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:
Alert-Toast-MK-Web-Notifications
Answer the question
In order to leave comments, you need to log in
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());
});
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 questionAsk a Question
731 491 924 answers to any question