Get the number of an element's pixels which are inside the viewport
问题 I'm trying to get the total number of a given html element's pixels which are visible inside the viewport. This question and accepted answer Can I detect the user viewable area on the browser? were very useful for determining whether the element is in view/out of view/partially in view, but for the partially in view case I need to get the total (vertical x horizontal) number of pixels not obscured by the viewport. I was trying something like this, but the horizontal value is always wrong: var