Detecting whether a div is visible

Is there a way to detect whether any given DIV is visible? I.e., not only is .style.visibility set to visible, but that it isn't inside any other element that makes it invisible. We can exclude any issues of the element being out of view because below the screen fold, or covered up by something else (although that would be neat). The problem I'm having is that when I detect a DIV's visibility attribute, this doesn't tell me if it is overridden by some other DIV.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

When you query for a div's attribute it will give you the specifics of the object or div in question.

try something like this... and see

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="">
<title>Div Test</title>
<script type="text/javascript">
function findVisibility(objektId,parentLevel){
	var objekt = document.getElementById(objektId);
	var parentCount = 0;
		if(( == "none")){
			alert("The object is invisible!");
		objekt = fetchParent(;
	} while(objekt && (parentCount<=parentLevel));
	alert("The object is visible!");

function fetchParent(objektId){
	return document.getElementById(objektId).parentNode;
<body id="contentBody">
<div id="test1">
	<div id="outerDiv1" style="display:block;">
		Outer Div Content 1
		<div id="innerDiv1" style="display:block;">
			Inner Div Content 1
	<input type="button" id="btnTest1" value="check div visibility 1" onclick="findVisibility('innerDiv1',1);">
<div id="test2">
	<div id="outerDiv2" style="display:block;">
		Outer Div Content 2
		<div id="innerDiv2" style="display:none;">
			Inner Div Content 2
	<input type="button" id="btnTest2" value="check div visibility 2" onclick="findVisibility('innerDiv2',1);">
<div id="test3">
	<div id="outerDiv3" style="display:none;">
		Outer Div Content 3
		<div id="innerDiv3" style="display:block;">
			Inner Div Content 3
	<input type="button" id="btnTest3" value="check div visibility 3" onclick="findVisibility('innerDiv3',1);">

<div id="test4">
	<div id="outerSec4" style="display:block;">
		<div id="outerDiv4" style="display:block;">
			Outer Div Content 4
			<div id="innerDiv4" style="display:block;">
				Inner Div Content 4
	<input type="button" id="btnTest4" value="check div visibility 4" onclick="findVisibility('innerDiv4',2);">

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
metalaureateAuthor Commented:
Thank you - helpful.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.