Forum Moderators: open

Message Too Old, No Replies

Working in IE but not Firefox?

Folding menu doesn't work in Firefox

         

Warboss Alex

4:44 pm on Jun 9, 2005 (gmt 0)

10+ Year Member



Hi everyone ..

Could someone tell me why this is working in IE and not Firefox please? It's doing my head in. It's a folding menu, when you click a menu item the submenu appears - works fine in IE but not Firefox!


<script type="text/javascript">

function checkcontained(event) {

var $iscontained = 0;

var $current = event.srcElement;

if ($current.id == "category") $iscontained = 1;

else {

while ($current.parentElement) {

if ($current.id == "category" ¦¦ $current.id =="sub") {

$iscontained = ($current.id=="category")? 1 : 0;

}

$current = $current.parentElement;

}

}

if ($iscontained) {

var $content = $current.getElementsByTagName('ul')[0];

if ($content.style.display=="none") {

$content.style.display="";

}

else {

$content.style.display="none";

}
}

}

</script>

<ul>
<li id="category" onClick="checkcontained()">Menu 1</li>
<ul id="sub" style="display:none;">
<li><a href="">Element1</a></li>
<li><a href="">Element2</a></li>
<li><a href="">Element3</a></li>
</ul>

<li id="category" onClick="checkcontained()">Menu 2</li>
<ul id="sub" style="display:none">
<li><a href="">Element1</a></li>
<li><a href="">Element2</a></li>
<li><a href="">Element3</a></li>
</ul>

</ul>

Hoping it's nothing too blatant and embarrassing .. thanks all!

Rambo Tribble

1:35 am on Jun 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



event.srcElement is IE-only. The comparable DOM 2 property is event.target.