jquery - javascript detect scrollbar not working -


i know question has been asked ad nauseum, stumped because after trying several different solutions, still cannot script detect scrollbar.

here function using try , detect scrollbar:

function checkscrollbar() {   var hcontent = $("body").height(); // height of content   var hwindow = $(window).height(); // height of visitor's browser window    if(hcontent>hwindow) { // if height of content bigger height of browser window, have scroll bar     return true;       }    return false; } 

the problem though on page there literally vertical scrollbar popping because content of page longer window on laptop, function still says window height equal body height.

i still newer javascript/jquery, please gentle if there major error have missed.

you need consider offset of page.

function checkscrollbar() {   var hcontent = $(document).height(); // height of content   var hwindow = $(window).height(); // height of visitor's browser window    if(hcontent>hwindow) { // if height of content bigger height of browser window, have scroll bar     return true;       }    return false; } 

example : http://jsfiddle.net/a2rnd/


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -