Check if a page has a vertical scrollbar or Horizontal Scrollbar using jQuery?


Please find below code to find scrollbar

jQuery(document).ready(function() {
    // Check if body height is higher than window height :)
    if (jQuery("body").height() > jQuery(window).height()) {
        alert("Vertical Scrollbar!");
    }

    // Check if body width is higher than window width :)
    if (jQuery("body").width() > jQuery(window).width()) {
        alert("Horizontal Scrollbar!");
    }
});
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s