dmpost dmpost - 6 months ago 48
Javascript Question

How CSS can disable window.onscroll?

The problem: Simple function doesn't called

window.onscroll = function() {
console.log("scroll");
}


It will work if I remove the CSS link from the page

<link rel="stylesheet" href="/blog/css/style.css" type="text/css">


The question:
How CSS code can disable Javascript function window.onscroll ?

The page: http://swimbi.com/blog/

The CSS : http://swimbi.com/blog/css/style.css

Answer

You are actually scrolling your container div. If you do this the events fire:

document.getElementById("container").onscroll = function() { 
    console.log("scroll container"); 
}

edit: looks like something changed on the page. If you use this on the above page it works correctly:

jQuery("body").on("scroll", function() { 
    console.log(this) 
})
Comments