We help IT Professionals succeed at work.

Detect using JS Only If element exists on Page and Is Visible

How would I detect if this element is on the current page and visible? Using JavaScript and NOT jQuery.

<p><strong>Before you Start</strong></p>

Open in new window


I'm fairly sure this function will suffice with detecting if visible.

    function _dtmIsVis(elem) {
        if (elem === null) {
            return false;
        }
        return !!(elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length);
    };

Open in new window


Thanks!
Comment
Watch Question

Commented:

 I was able to do this using DTM.