Is there any technique or set of techniques that can be used to implement what, in effect, would be an onVisible 'event' in JavaScript?

I would like my JavaScript to detect when an element in a web page, such as a paragraph of text, or an image, becomes visible in a browser window as a user scrolls down a page. I would also like a corresponding 'event', onNotVisible, to fire when an element that was once visible in the browser window can no longer be seen.

If it cannot be easily implemented in JavaScript, are there any browser specific events that can provide the same functionality?

Edit
Report