onscroll won't work with IE

谁说我不能喝 提交于 2019-12-22 06:00:08

问题


i have a "body" with onScroll="Scroll()". Scroll method should, well, scroll some div as user scrolls the page.

Scroll():

function Scroll()
{
    var el = document.getElementById('controlBox');
    var ScrollTop = document.body.scrollTop;
    el.style.top = ScrollTop + "px";
}

It works fine with Chrome and FF, but IE won't cooperate. What's wrong here?


回答1:


Remove the onScroll from your body tag, and try adding

window.onscroll = Scroll;

to your javascript, outside of the function.



来源:https://stackoverflow.com/questions/4709673/onscroll-wont-work-with-ie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!