Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

onscroll won't work with IE

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?

like image 437
guest86 Avatar asked Jan 17 '11 03:01

guest86


1 Answers

Remove the onScroll from your body tag, and try adding

window.onscroll = Scroll;

to your javascript, outside of the function.

like image 74
Scott Avatar answered Sep 19 '22 13:09

Scott