Handle window scroll event in greasemonkey script

Posted by Akim Khalilov on Stack Overflow See other posts from Stack Overflow or by Akim Khalilov
Published on 2010-05-04T19:13:56Z Indexed on 2010/05/04 19:18 UTC
Read the original article Hit count: 267

Hi.

I need some advice. I have a web page and want to extend it's functionality with greasemonkey script and firefox.

When page has loaded I need run custom function during user's page scrolling (with mouse whell or scrollbar). I want show some div block when user scrolling down and hide it when he scrolling to the top.

But I met some problem - I couldn't assign event handler to the onscroll event. I use next part of the code:

function showFixedBlock(){ ... }
function onScrollStart(){ ... showFixedBlock(); ... }
window.onscroll = onScrollStart;

I test this piece of code on my test html page and it works, but when I copy it into greasemonkey, script doesn't work.

Should I assign onscroll event handler during page loading? As I know greasemonkey execute it's scripts when page has loaded? Is it the reason of the problem?

Is there some additional requirments to handle 'onscroll' event? How can I do that?

Thanks.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about greasemonkey