Hello all,
I have in the past been loading a .js file at the bottom of the page to perfom a function on my menu format and layout, however i have been cleaning up my code lately and have been moving alot of functions to "window.onload = function()"
My question is this: Can someone help me out with the best way to add the code below to the window.onload = function() { } of my .js file that i load at the top of the page.... I have been playing with this for weeks, however i think i am too close to it and can't seem to find where i am going wrong.
Any and all help/suggestions appreciated!Code:function addEvent(obj, evType, fn){ if (obj.addEventListener){ obj.addEventListener(evType, fn, true); return true; } else if (obj.attachEvent){ var r = obj.attachEvent("on"+evType, fn); return r; } else { return false; } } if (document.getElementById('left_menu')?true:false != false) { var list = document.getElementById("left_menu").getElementsByTagName("ul"); for(i = 1; i < list.length; i++){ if(String(list[i].parentNode.nodeName).toLowerCase() == 'li') { addEvent(list[i].parentNode, 'click', doIT); } } } if (document.getElementById('left_menu'||'top_nav')?true:false != false) { document.write("<style> div#left_menu ul ul { display:none; } </style>"); var theLink = document.links; for (var l=0; l < theLink.length; l++) if (location.href == theLink[l]||location.href == theLink[l]+'#') { theLink[l].id = 'selected'; var subLink = theLink[l].parentNode.parentNode.parentNode; var subMenu = theLink[l].parentNode.parentNode; if (String(subLink.nodeName).toLowerCase() == 'li') { subLink.id = 'selected'; subMenu.id = 'selected'; } } } function doIT() { if (document.attachEvent) { var theEl = window.event.srcElement.parentNode; } else { var theEl = this; } u=theEl.getElementsByTagName("ul")[0]; u.style.display=(u.style.display=='none'||u.style.display=='')?'block':'none'; }![]()



Reply With Quote

Bookmarks