<div id="lazyblock"> <script> function lazyblock(){ var wt = $(window).scrollTop(); //* top of the window var wb = wt + $(window).height(); //* bottom of the window $("#lazyblock").each(function(){ var ot = $(this).offset().top; //* top of object (div) var ob = ot + $(this).height(); //* bottom of object if(!$(this).attr("loaded") && wt<=ob && wb >= ot){ $(this).html('<iframe src="/block.html" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:211px; height:790px;" allowTransparency="true"> </iframe>'); $(this).attr("loaded",true); } }); } $(document).ready(function(){ $(window).scroll(lazyblock); lazyblock(); }); </script> </div>
Оставить комментарий