function isScrolledIntoView(elem) { var docViewTop = jQuery(window).scrollTop(); var docViewBottom = docViewTop + jQuery(window).height(); var elemTop = jQuery(elem).offset().top; var elemBottom = elemTop + jQuery(elem).height(); return ( (elemTop <= docViewBottom) && (elemTop >= docViewTop) || (elemBottom <= docViewBottom) && (elemBottom >= docViewTop) ); } jQuery('#our_a_top').html('
');function renderATop() { window.yaContextCb.push(()=>{ Ya.Context.AdvManager.render({ blockId: "R-A-645045-1", renderTo: "yandex_rtb_R-A-645045-1" }) }); } renderATop(); setInterval(function(){ if (isScrolledIntoView('#yandex_rtb_R-A-645045-1')) { console.log('Reload top block'); renderATop(); } }, 30000);