M
M
master2909882021-06-25 16:14:33
JavaScript
master290988, 2021-06-25 16:14:33

How to add a visibility check?

There is a code on the site that reloads the container every 30 seconds
. Here is the container: Here is the script that does the reload:
<div id="adfox_154394132037159997"></div>

<script>setInterval(function(){ window.Ya.adfoxCode.reload(adfox_154394132037159997); }, 30000);</script>

It is necessary to make the container reload only when it is in the browser's visibility zone, that is, when the visitor has scrolled to it.

What should be added to the script so that it takes into account the scope and starts counting when it is in it and stops reloading when it is not in the scope?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Markov, 2021-06-25
@En-Tilza

Try this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question