I have recently been researching using JS to create expandable sections within a form and have come across a fairly simple example and ahve been testing it and playing about with it but i noticed when cross browser testing that there were slight errors for some reason! I shall post the code and then explain the problem.....
The problem i have found is that when i use IE the main buttons such as MENU 1, 2 and 3, do expand and show an extra 3 links the actual MENU buttons disappear, However when testing this in FireFox they do not disappear and the user can easily close the expanded links!
Anyone got any ideas why this is? i have been playing about with the code with no success =[
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="Javascript" type="text/javascript" src="/js/cnt.js"></script>
<script language="Javascript">
//Menu Set-Up Javascript
var ns6=document.getElementById&&!document.all?1:0
var head="display:''"
var folder=''
function expandit(curobj){
folder=ns6?curobj.nextSibling.nextSibling.style:document.all[curobj.sourceIndex+1].style
if (folder.display=="none")
folder.display=""
else
folder.display="none"
}
</script>
<? $isiepos = strpos($HTTP_USER_AGENT,"MSIE");
$isie = ( $isiepos>0 ? substr($HTTP_USER_AGENT,$isiepos+5,3) : 0 );
list($isnsver,$d) = explode(" ",$HTTP_USER_AGENT);
$isnsver = ( substr($isnsver,0,8)=="Mozilla/" ? substr( $isnsver,8 ) : 0 );
$isns = ( $isnsver>4.0 ? $isnsver : 0 );
if($isie==0)
{
$netscape=true;
}
else
{
$netscape=false;
}
$opera=0;
$br = strtolower(getenv("HTTP_USER_AGENT"));
if(ereg("opera", $br) && !ereg("7.", $br)) { $opera=true; }
?>
<? if ($opera)
{
?>
<? } ?>
</head>
<body>
<? if($opera) { ?><div id="menu1" onclick="showhide(menu1in,menu1out)"><img src="images/menu1.gif" name="menu1out" width="120" height="30" border="0" id="menu1out"></div>
<span id="menu1in" style="display:'none'"><? } else { ?>
<div style="cursor:hand" <? if ($netscape) echo "onclick=\"expandit(this)\""?>><img src="images/menu1.gif" width="120" height="30" border="0" onclick="expandit(this)"></div>
<span style="display:none; &{head}"><? } ?>
<a href="link1.html"><img src="images/link1.gif" width="120" height="30" border="0"></a><br>
<a href="link2.html"><img src="images/link2.gif" width="120" height="30" border="0"></a><br>
<a href="link3.html"><img src="images/link3.gif" width="120" height="30" border="0"></a><br></span>
<? if($opera) { ?><div id="menu2" onclick="showhide(menu2in,menu2out)"><img src="images/menu2.gif" width="120" height="30" border="0" id="menu2out"></div>
<span id="menu2in" style="display:'none'"><? } else { ?>
<div style="cursor:hand" <? if ($netscape) echo "onclick=\"expandit(this)\""?>><img src="images/menu2.gif" width="120" height="30" border="0" onclick="expandit(this)"></div>
<span style="display:none; &{head}"><? } ?>
<a href="link1.html"><img src="images/link1.gif" width="120" height="30" border="0"></a><br>
<a href="link2.html"><img src="images/link2.gif" width="120" height="30" border="0"></a><br>
<a href="link3.html"><img src="images/link3.gif" width="120" height="30" border="0"></a><br></span>
<? if($opera) { ?><div id="menu3" onclick="showhide(menu3in,menu3out)"><img src="images/menu3.gif" width="120" height="30" border="0" id="menu3out"></div>
<span id="menu3in" style="display:'none'"><? } else { ?>
<div style="cursor:hand" <? if ($netscape) echo "onclick=\"expandit(this)\""?>><img src="images/menu3.gif" width="120" height="30" border="0" onclick="expandit(this)"></div>
<span style="display:none; &{head}"><? } ?>
<a href="link1.html"><img src="images/link1.gif" width="120" height="30" border="0"></a><br>
<a href="link2.html"><img src="images/link2.gif" width="120" height="30" border="0"></a><br>
<a href="link3.html"><img src="images/link3.gif" width="120" height="30" border="0"></a><br></span>
</body>
</html>
The problem i have found is that when i use IE the main buttons such as MENU 1, 2 and 3, do expand and show an extra 3 links the actual MENU buttons disappear, However when testing this in FireFox they do not disappear and the user can easily close the expanded links!
Anyone got any ideas why this is? i have been playing about with the code with no success =[