473,385 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Recursive parsing of navigation list (UL LI UL LI etc) tree fails, why?

Hi all :)

I'm trying to get the functionality gained using only CSS in Opera/Gecko
etc on this page:
<http://matt.blissett.me.uk/web/authoring/css_menus/sample> to work in IE,
using javascript. My attempt is here:
<http://matt.blissett.me.uk/web/authoring/css_menus_with_javascript/sample>

The script is only parsed with IE. Why do I get an infinite loop? I have a
menu structure like this (abbreviated):

<ul id="nav">
<li>...</li>
<li>...</li>
<li>
<ul>
<li>...</li>
<li>
<ul>
<li>...</li>
<li>...</li>
<li>
<ul>
<li>...</li>
</ul>
</li>
</ul>
</li>
<li>...</li>
</ul>
<li>...</li>
</ul>

I'm using a css :hover on the LI elements to change the visibility of
their child UL elements to visible. For IE, I'm adding the class 'over' to
the LI instead. I want to do this:

when the document loads,
find the nav element,
look at it's children: --
if the child is an LI |
add the 'magic' (over class bits) |
in any case |
go through the indicated script with this element |
--

It fails, however, IE gives it's error about a script taking too long, and
crashed if I don't stop it. If I do stop it, I get some functionality --
where is it looping too much?

URL in case you missed it:
<http://matt.blissett.me.uk/web/authoring/css_menus_with_javascript/sample>

javascript:
<http://matt.blissett.me.uk/web/authoring/css_menus_with_javascript/css_menus_magic>
Aside: this is my first proper venture into Javascript, I'm impressed with
the language, it wasn't what I was expecting :)

Thanks :-)

--
Matt
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 23 '05 #1
1 2714
Matt wrote:
The script is only parsed with IE. Why do I get an infinite loop? for (j=0; j<someNode.childNodes.length; j++) {
Omitting the "var" keyword in a variable declaration makes the variable
global. As you can imagine, this is not something you want to do in a
recursive script:-)

for(var j=...

should prove helpful (untested).
node.onmouseover=function() {
this.className+=" over";
}
Note that using a function expression like this in a loop is likely to
prevent function optimization - this means you're creating one function
object per iteration, while one function object would be sufficient -
just declare the function outside the iteration, be it in the global
scope or using a closure.
Aside: this is my first proper venture into Javascript, I'm impressed with
the language, it wasn't what I was expecting :)


Let's hope you'll find your adventure enjoyable; as for now I've played
with many languages, from many families, and javascript is by far my
favorite one.
HTH
Yep.
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Marek Mänd | last post by:
How to create an UL LI navigation list/toolbar where the tabs are placed from the left to the right, but some of the tabs are placed on the right in that toolbar, so a sort of fexible-width gap...
2
by: MTT | last post by:
Hi there I like to know if any class avilable before proceeding on my work. I need a inverted list behaviour for sequential access of elements for both direction (previous(),next()) also...
25
by: prabhat143 | last post by:
Hi, Given a singly linked, null terminated list, how can it be converted to tree? Each node in the list has three attributes: it's ID, it's parent ID and of course, the next node it's pointing...
12
by: Chris | last post by:
Are there any other controls which could replace List & Tree controls, because they have limitation of accepting only 32767 items. thanks a lot in advance.
1
by: xian83 | last post by:
I am trying all day to make some things straight but nothing helps... Me and my collegue have built a c++ tree of a class VO. I tend to refer to the structure as a tree and not a simple list...
1
by: David Bilsby | last post by:
All Apologies for cross posing this but I am not sure if this is a VC 8 STL bug or simply an invalid use of the iterator. I have a PCI card access class which basically abstracts a third party...
4
by: =?ISO-8859-1?Q?Fran=E7ois_de_Dardel?= | last post by:
Here is the page: http://dardel.info/museum/Museum1.html and here is the CSS (see navigation buttons at bottom of file): http://dardel.info/museum/style3.css Is there a way to make all nav...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.