/* Javascript */
var benefitpub=document.getElementById('pubbox');
var advbox2=document.getElementById('advbox');
if (document.body.scrollTop > benefitpub.getBoundingClientRect().top+'px'){benefitpub.style.visibility='visible';}
if (document.body.scrollTop > advbox2.getBoundingClientRect().top+'px'{advbox2.style.visibility='visible';}
<!-- CSS -->
#advbox, #pubbox{margin-top:500px;visibility:hidden;}
<!-- HTML -->
<div id="advbox">
Hello This is advbox
</div>
<div id="pubbox">
Hello this is Pubbox
</div>
以上是我的代码,请告诉我如何在窗口滚动到#advbox
和#pubbox
元素的位置时显示元素#advbox
和#pubbox
!我很困惑哪些地方错了。
预先感谢