![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||||||||
| |||||||||
|
|
I have this script and I want to adapt it to the DOM of most / all well known browsers like mozilla and netscape.. at the moment it only works in ie4+ en ns6. can anybody give me some hints ?!? |
|
This is used for making a tree <li><ul var ns6 = document.getElementById && !document.all; var ie4 = document.all && navigator.userAgent.indexOf("Opera") == -1; |
|
function checkcontained(e) { var iscontained = 0; cur = ns6 ? e.target : event.srcElement; |

|
while (ns6 && cur.parentNode || (ie4 && cur.parentElement)) |
|
if (cur.id == "foldheader" || cur.id == "foldinglist") { iscontained = (cur.id == "foldheader") ? 1 : 0; |
|
cur = ns6 ? cur.parentNode : cur.parentElement; |
|
var foldercontent = ns6 ? cur.nextSibling.nextSibling : cur.all.tags("UL")[0]; |
|
if (foldercontent.style.display == "none") |
|
document.onclick = checkcontained; |
#2
| |||||
| |||||
|
|
"Daniel" <dvdoord (AT) planet (DOT) nl> writes: I have this script and I want to adapt it to the DOM of most / all well known browsers like mozilla and netscape.. at the moment it only works in ie4+ en ns6. can anybody give me some hints ?!? Which browsers have you tried it in? |
|
What error messages did they give? |
|
Which browsers are you not supporting? E.g., not dinosaurs like Netscape 4, where supporting it basically means writing two versions of everything. It seems you are ignoring NS 4 (smart!). |
|
var foldercontent = ns6 ? cur.nextSibling.nextSibling : cur.all.tags("UL")[0]; var foldercontent; if (cur.nextSibling) { foldercontent = cur.nextSibling.nextSibling; } else if (cur.getElementsByTagName) { foldercontent = cur.getElementsByTagName("ul")[0]; } else if (cur.all && cur.all.tags) { foldercontent = cur.all.tags("UL")[0]; } |

stripped the rest.. ![]() |

#3
| |||
| |||
|
|
NS6 gives the error that the foldercontent has no properties |
|
I wanna support at least NS6, Mozilla and IE6 and maybe 5 the most common used once... |
|
var foldercontent = ns6 ? cur.nextSibling.nextSibling : cur.all.tags("UL")[0]; var foldercontent; if (cur.nextSibling) { foldercontent = cur.nextSibling.nextSibling; } else if (cur.getElementsByTagName) { foldercontent = cur.getElementsByTagName("ul")[0]; } else if (cur.all && cur.all.tags) { foldercontent = cur.all.tags("UL")[0]; } Unfortunately this didn't work The menu structure was very disturbed ![]() |
#4
| |||
| |||
|
|
"Daniel van den Oord" <daniel304 (AT) planet-maps-on (DOT) nl> writes: NS6 gives the error that the foldercontent has no properties Ok, that probably means that foldercontent is null or undefined. I wanna support at least NS6, Mozilla and IE6 and maybe 5 the most common used once... Aiming for standards should give you Mozilla and Netscape 7 (and Netscape 6 if you avoid the bugs ... it is based on a pre-1.0 version of Mozilla and has some bugs) |

| var foldercontent = ns6 ? cur.nextSibling.nextSibling : cur.all.tags("UL")[0]; var foldercontent; if (cur.nextSibling) { foldercontent = cur.nextSibling.nextSibling; } else if (cur.getElementsByTagName) { foldercontent = cur.getElementsByTagName("ul")[0]; } else if (cur.all && cur.all.tags) { foldercontent = cur.all.tags("UL")[0]; } Unfortunately this didn't work The menu structure was very disturbed ![]() Thinking about it, it is not that supricing. The oringinal expression didn't make much sense either: var foldercontent = ns6 ? cur.nextSibling.nextSibling : cur.all.tags("UL")[0]; |

|
If it is NS6, you let foldercontent be a sibling of the cur node. That is, they are nodes on the same level, having the same parent node. If it is not NS6, you find a child node of the cur node. So, which is it? Without knowing the structure of the HTML it is hard to guess which it should be, but since it works in IE, the problem is probably the nextSibling part. I would just skip it and use: var foldercontent; if (cur.getElementsByTagName) { foldercontent = cur.getElementsByTagName("ul")[0]; } else if (cur.all && cur.all.tags) { foldercontent = cur.all.tags("UL")[0]; } That should at least do the same thing in both Mozilla and IE. |
here it is.. partially 
#5
| |||
| |||
|
|
Well I wished still nothing in foldercontent... I'm sorry I totally forgot about the html code here it is.. partially ![]() div style="position:relative;left:-24" ul li id="foldheader"> Modulen</li ul id="foldinglist" style="display:none" style=&{head}; |
#6
| |||
| |||
|
|
"Daniel van den Oord" <daniel304 (AT) planet-maps-on (DOT) nl> writes: Well I wished still nothing in foldercontent... I'm sorry I totally forgot about the html code here it is.. partially![]() div style="position:relative;left:-24" ul li id="foldheader"> Modulen</li ul id="foldinglist" style="display:none" style=&{head}; Ok, have you ever validated this code? (Hint: it won't) You are not allowed to have ul elements as direct children of other ul elements. They must be inside an li element. That is, a menu item is something like li>Modulen ul ... /ul li The submenu of Modulen is inside the same li element as the title. If written like that, the getElementsByTagName/all.tags code should find the submenu correctly. |
![]() |
| Thread Tools | |
| Display Modes | |
| |