I need to know, whet开发者_C百科her a vertical scrollbar has appeared or not in browser window. Is it possible using jQuery or any other way?
Like this:
if (document.documentElement.scrollHeight === document.documentElement.clientHeight) {
//There is no vertical scrollbar
}
This doesn't work in IE
This is an old post but I finally got the code that also works on IE7. Hope this can help someone.
var hasScrollbar = $('body').outerHeight() > $(window).height();
Compare the document height with the window height. If it's more there's probably a scrollbar unless you disabled it.
精彩评论