"Lasse Reichstein Nielsen" <lr*@hotpop.com> schreef in bericht
news:u1**********@hotpop.com...
"Daniel" <dv*****@planet.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?
Currenly I am trying this in Mozilla 1.4 and IE6
What error messages did they give?
IE6 doesn't give any errors..
NS6 gives the error that the foldercontent has no properties
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!).
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 :(
>> stripped the rest.. :)
new code
//*******
// Still needing the next 2 lines :(
//*******
var ns6 = document.getElementById && !document.all;
var ie4 = document.all && navigator.userAgent.indexOf("Opera") == -1;
function checkcontained(variable)
{
if (typeof variable == 'undefined') variable = window.event;
var cur = (typeof variable.target != 'undefined') ? variable.target :
variable.srcElement;
var iscontained = 0;
if (cur.id == "foldheader")
{
iscontained = 1;
}
else
{
while ( cur.parentNode || cur.parentElement )
{
if (cur.id == "foldheader" || cur.id == "foldinglist")
{
iscontained = (cur.id == "foldheader");
break;
}
cur = cur.parentNode || cur.parentElement;
}
}
if (iscontained)
{
//*******
// Here it goes wrong
//*******
var foldercontent = ns6 ? cur.nextSibling.nextSibling :
cur.all.tags("UL")[0];
if (foldercontent.style.display == "none")
{
foldercontent.style.display = "";
cur.style.listStyleImage = "url(images/open.gif)";
}
else
{
foldercontent.style.display = "none";
cur.style.listStyleImage = "url(images/fold.gif)";
}
}
}
if (document.addEventListener)
{
document.addEventListener("click",checkcontained,f alse);
}
else if (document.attachEvent)
{
document.attachEvent("onclick",checkcontained);
}
else
{
document.onclick = checkcontained;
}