Re: Javascript menu modifications
Rob B wrote:[color=blue]
> Resubmitted:
>
> Or...
>
> function initMenu(item)
> {
> var menus, menu, text, a, i;
> if (item) item = new RegExp(item);
> menus = getChildrenByEl ement(document. getElementById( "menu"));
> for(i = 0; i < menus.length; i++)
> {
> menu = menus[i];
> text = getFirstChildBy Text(menu);
> a = document.create Element("a");
> menu.replaceChi ld(a, text);
> a.appendChild(t ext);
> a.href = "#";
> a.onclick = showMenu;
> a.onfocus = function(){this .blur()};
> if (item && item.test(text. nodeValue))
> a.onclick();
> }
> }
>
> ..and in specific pages:
>
> if(document.cre ateElement)
> window.onload = function()
> {
> initMenu('Menu Item 3');
> }[/color]
If you are going to post code that will error-out and fail
uncontrollably on known user agents (due to inadequate feature
detection), the least you should do is list the subset of browsers on
which you know it should work, so that readers can appreciate how far
short of being cross-browser they can expect your code to be.
Richard.
Rob B wrote:[color=blue]
> Resubmitted:
>
> Or...
>
> function initMenu(item)
> {
> var menus, menu, text, a, i;
> if (item) item = new RegExp(item);
> menus = getChildrenByEl ement(document. getElementById( "menu"));
> for(i = 0; i < menus.length; i++)
> {
> menu = menus[i];
> text = getFirstChildBy Text(menu);
> a = document.create Element("a");
> menu.replaceChi ld(a, text);
> a.appendChild(t ext);
> a.href = "#";
> a.onclick = showMenu;
> a.onfocus = function(){this .blur()};
> if (item && item.test(text. nodeValue))
> a.onclick();
> }
> }
>
> ..and in specific pages:
>
> if(document.cre ateElement)
> window.onload = function()
> {
> initMenu('Menu Item 3');
> }[/color]
If you are going to post code that will error-out and fail
uncontrollably on known user agents (due to inadequate feature
detection), the least you should do is list the subset of browsers on
which you know it should work, so that readers can appreciate how far
short of being cross-browser they can expect your code to be.
Richard.
Comment