简体   繁体   English

onscroll不适用于IE

[英]onscroll won't work with IE

i have a "body" with onScroll="Scroll()" . 我有一个onScroll="Scroll()"的“body onScroll="Scroll()" Scroll method should, well, scroll some div as user scrolls the page. 当用户滚动页面时,滚动方法应该滚动一些div。

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. 它适用于Chrome和FF,但IE不会合作。 What's wrong here? 这有什么不对?

Remove the onScroll from your body tag, and try adding 从身体标签中删除onScroll,然后尝试添加

window.onscroll = Scroll;

to your javascript, outside of the function. 到你的javascript,在函数之外。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM