开发者

onscroll won't work with IE

开发者 https://www.devze.com 2023-02-04 08:55 出处:网络
i have a \"body\" with o开发者_Python百科nScroll=\"Scroll()\". Scroll method should, well, scroll some div as user scrolls the page.

i have a "body" with o开发者_Python百科nScroll="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?


Remove the onScroll from your body tag, and try adding

window.onscroll = Scroll;

to your javascript, outside of the function.

0

精彩评论

暂无评论...
验证码 换一张
取 消