Detect if a page has a vertical scrollbar?

javascript, jquery, scroll

Solution

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

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

Problem

I just want some simple JQ/JS to check if the current page/window (not a particular element) has a vertical scrollbar. Googling gives me stuff that seems overly complex for just this basic feature. How can this be done?

Original source

Related problems