E
E
Elizaveta Rubtsova2018-02-07 19:46:18
PHP
Elizaveta Rubtsova, 2018-02-07 19:46:18

How to implement two pop-up banners so that they pop up once per session (at 12 o'clock) in turn?

The site has a popup banner that is displayed every 12 hours
const banner = $('.popup-banner');
let bannerName = banner.attr('cookie-data');
if (!$.cookie(bannerName)) {
setTimeout(function() {
$(".popup-shadow").fadeIn(200);
banner.addClass('popup-opened');
banner.fadeIn(300);
}, 5000);
}
$(".popup-banner a").click(function() {
let cookieName = $(this).parents('.popup-banner').attr('cookie-data');
var date = new Date ();
var hours = 12;
date.setTime(date.getTime() + (hours * 60 * 60 * 1000));
$.cookie(cookieName, true, {
expires: date,
path: '/'
});
});
but you need to make two such banners so that they are displayed either once every 12 hours or once per session in a checkerboard pattern (in turn), i.e. first session banner 1 second banner 2 third banner 1 etc. ? With what can this be done?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Boris Korobkov, 2018-02-07
@BorisKorobkov

once per session

Use PHP session
Cookie or saving to the database (if the user is logged in)
PS In general, all pop-up banners are blocked by default by browsers. Last resort plugins. So it's better to do at least something useful for the site.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question