
Originally Posted by
AppsWorld
I think getting navigating to the top of the DOM structure is not a good practice.
On the contrary, I think that is a good practice. Well, not exactly to the top of the DOM structure, but to a certain parent, An example:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<style type="text/css">
#container{
background-color: #999999;
height: 100px;
width: 100px;
}
table{
background:#99FFCC;
border:none;
width:50px;
}
</style>
<script type="text/javascript">
document.onclick=check;
function check(e){
var target = (e && e.target) || (event && event.srcElement);
var obj = document.getElementById('container');
checkParent(target)?obj.style.display='none':null;
}
function checkParent(t){
while(t.parentNode){
if(t==document.getElementById('container')){
return false
}
t=t.parentNode
}
return true
}
</script>
</head>
<body>
<div id="container">
<table cellpadding="2" cellspacing="1">
<tr>
<td>click</td>
<td>ouside</td>
</tr>
<tr>
<td>to hide</td>
<td>the div</td>
</tr>
</table>
</div>
</body>
</html>
Bookmarks