开发者

How to know if the scrollbars has appeared in browser (jQuery)?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜