U
U
Uzair Izha2015-11-05 16:03:41
JavaScript
Uzair Izha, 2015-11-05 16:03:41

How to make a module window appear periodically on the page?

It is necessary that the module window periodically appear on the page, the module window itself is not a problem, but how to make time intervals, for example, every hour or 30 minutes. That is, an hour passed for the module window to appear.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
Mikhail Osher, 2015-11-05
@miraage

Out of loyalty to users, I won’t specifically tell you how to do this.
I hate those stupid modals.

S
Serdji, 2015-11-05
@ssumatokhin

setInterval(function  () {
  // body...
}, 180000) // 30 минут

V
Vladimir, 2015-11-05
@Vovchikvoin

Since the site is not a SPA, the method with setTimeout will not help, it is necessary to write the current time on the first page load (timeFromCookie = Date.now() - for example), in the cookie or localStorage - in order to then take this time and compare it with the current one, and watch how long has passed: (Date.now()- timeFromCookie) / (1000 * 60 * 30) > 1 - if the expression is true, then more than half an hour has passed. To compare, you can write a function using setInterval, which, say, once a minute will check the current time and the time from the storage. And run it immediately when the page loads.

M
mr_dev1l, 2015-11-06
@mr_dev1l

You have a good site, since users sit on it for an hour

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question