Malasorte Malasorte - 1 year ago 144
jQuery Question

If document can be scrolled vertically by 200px or more run function

Using Jquery or plain Js I want to run a function on

document ready
, if the page has a vertical scrollbar and the ammount by wich the page can be scrolled is
or larger.

Basically, I want to modify the code below so that it runs on
document ready
, not when the user actually scrolls.

if ($(this).scrollTop() > 200) {
// do stuff

Answer Source

This is how i would do it.

$(document).ready(function() {
  if(($(document).height() - $(window).height()) > 200)
     //Do something.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download