javascript - scrollHeight is more than clientHeight, even without scrolling content -


i have piece of js code determines whether there vertical scrollbar , applies css class element. nothing big. confusing me appears doing opposite of understand should doing. isn't problem unless bug , fixed in future.
code:

if (document.body.scrollheight > document.body.clientheight) {     var d = document.getelementbyid("footer").classname = "footernoscroll"; } 

my understanding apply class if there vertical scroll bar, appears applying class if there isn't scroll bar. interpreting correctly , code acting strangely or interpretation wrong?

edit: thought should add, if reverse operator effects reversed , use else part of statement instead.

make sure body 100% of window height. if don't have clientheight value combined height of items within body , not full window height, whereas scrollheight will full height of window.

here's fiddle shows working (open dev tools , view console): http://jsfiddle.net/alexcoady/c53d7q27/1/

html, body {     height: 100%;     padding: 0;     margin: 0; } 

clientheight documentation
scrollheight documentation


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -