from MDN)
isInPage (Example
This function checks to see if an element is in the page's body. As contains is inclusive and determining if the body contains itself isn't the intention of isInPage this case explicitly returns false.
function isInPage (node) {
return (node === document.body) ? false : document.body.contains(node)
}
npm usage
var isInPage = require('is-in-page')
if (isInPage(document.getElementById('wow'))) {
console.log('cool')
}