Is there a way to tell if an object is visible to the user (not scrolled off the screen)?
if (section.style.visibility == 'visible') alert('I can see it.');
if (section.style.visibility == 'hidden') alert('Where is it?');
<div id=section style="visibility:hidden;">YOU CANT SEE ME!</div>
Close, but not quite. I need a way to test to see if an object is on the screen or scrolled off the screen.
locate the object's X and Y coordinates on the page, and grab the user's availHeight and availWidth, if the object's X/Y values are greater than the availHeight and availWidth, then it's off the screen.
I tried looking for a function/method that returns the X/Y coords of a particular object. Do you know of a particular function that returns this info?
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)