First off let me say this, I find the concept interesting, and it seems to work well. However, there are a lot of problems with the code that I see. So in no particular order...
-The menu syntax is weird. What if you want to use the | in the test or image. Sub-arrays would be smarter.
-Misuse of parseInt
Code:
this.index = parseInt(this.parent.items.length,10);
The above code doesn't need to be converted to a number, it should already be one, and even if it does need converted just use the Number constructor.
-IE only code?
Code:
if(document.attachEvent)
{
temp_obj = document.getElementById("id_a"+x);
//temp_obj.attachEvent("onmouseover",function(){rollover('id'+randId,picDir+tempAr[3]);highlight('id'+randId+'');goTo=tempAr[0];} );
//temp_obj.attachEvent("onmouseout",function(){rollover('id'+randId,picDir+tempAr[2]);lowlight('id'+randId+'');goTo='';} );
temp_obj.onmouseover = function(){rollOver(this);goTo=tempAr[0];};
temp_obj.onmouseout = function(){rollOver(this);goTo='';};
}
In the above code you seem to test for IE's attachEvent(and maybe Opera,can't remember), but then you use the old style of events, which is fine. But this either outdated code, or browser sniffing. Both are bad.
-Browser Sniffing
Code:
var ie5 = document.all;
Ok, now that is browser sniffing for sure. Use Conditional Compilation, it's safer.Opera, Firefox, and all versions of IE6-7 actually support document.all. This is only working because Firefox actively lies to you.
-Browser Sniffing(again)
Code:
if(navigator.appName == "Microsoft Internet Explorer" && parseFloat(navigator.appVersion.split("MSIE")[1]) > 5.5 && el.src.toUpperCase().substring(el.src.length-3, el.src.length) === "PNG") //if ie and png
{
el.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+el.src+"',sizingMethod='scale')";
}
}
Use Conditional Compilation, trust me.
-Nested if-else-if-else staments
Code:
else
{
if(document.attachEvent)
{
Use else if, it's more readable.
-Why?
Code:
function returnFalse()
{
return false;
}
As you can see, my biggest complaint is that this isn't really cross-browser. IE support is held together by metaphorical duck tape(document.all). It's liable to break at any time. If you spend the time to make this truly cross-browser, it would be much better. Also, I found the formatting of all the code odd. Consistent spacing makes code more readable, but that is your choice.
Bookmarks