Brian W Posted September 24, 2008 Share Posted September 24, 2008 I am having problems with my Extending menu script. I got the script from http://javascript.internet.com/navigation/expanding-menu.html, I would put this in third party scripts, but there isn't a board for third party JS. Here is where it is being implemented http://www.recruitdonors.com/index.html In IE (no problems in Firefox) the menu mostly works but the menu selection -OFFICE SUPPLIES- does not work. See the link to the site and the source code (the index page is not PHP, it is plain HTML) and please see http://www.recruitdonors.com/menu.js for the javascript or below. /* This script and many more are available free online at The JavaScript Source :: http://javascript.internet.com Created by: Travis Beckham :: http://www.squidfingers.com | http://www.podlob.com version date: 06/02/03 :: If want to use this code, feel free to do so, but please leave this message intact. (Travis Beckham) */ // Node Functions if(!window.Node){ var Node = {ELEMENT_NODE : 1, TEXT_NODE : 3}; } function checkNode(node, filter){ return (filter == null || node.nodeType == Node[filter] || node.nodeName.toUpperCase() == filter.toUpperCase()); } function getChildren(node, filter){ var result = new Array(); var children = node.childNodes; for(var i = 0; i < children.length; i++){ if(checkNode(children[i], filter)) result[result.length] = children[i]; } return result; } function getChildrenByElement(node){ return getChildren(node, "ELEMENT_NODE"); } function getFirstChild(node, filter){ var child; var children = node.childNodes; for(var i = 0; i < children.length; i++){ child = children[i]; if(checkNode(child, filter)) return child; } return null; } function getFirstChildByText(node){ return getFirstChild(node, "TEXT_NODE"); } function getNextSibling(node, filter){ for(var sibling = node.nextSibling; sibling != null; sibling = sibling.nextSibling){ if(checkNode(sibling, filter)) return sibling; } return null; } function getNextSiblingByElement(node){ return getNextSibling(node, "ELEMENT_NODE"); } // Menu Functions & Properties var activeMenu = null; function showMenu() { if(activeMenu){ activeMenu.className = ""; getNextSiblingByElement(activeMenu).style.display = "none"; } if(this == activeMenu){ activeMenu = null; } else { this.className = "active"; getNextSiblingByElement(this).style.display = "block"; activeMenu = this; } return false; } function initMenu(){ var menus, menu, text, a, i; menus = getChildrenByElement(document.getElementById("menu")); for(i = 0; i < menus.length; i++){ menu = menus[i]; text = getFirstChildByText(menu); a = document.createElement("a"); menu.replaceChild(a, text); a.appendChild(text); a.href = "#"; a.onclick = showMenu; a.onfocus = function(){this.blur()}; } } if(document.createElement) window.onload = initMenu; Internet explore tells me this Line: 79 Char: 5 Error: Invalid Argument. Code: 0 URL: http://www.recruitdonors.com/ I looked at line 79, it makes a little since since that is the end of the non working menu item. <li>OFFICE SUPPLIES <ol> <div align="right"><a href="writing.php">WRITTING SUPPLIES</a></div> <div align="right"><a href="flashdrives.php">FLASH DRIVES</a></div> <div align="right"><a href="cardholder.php">CARD HOLDERS</a></div> LINE79->></ol> </li> BTW, I modified the script from having <li>'s to having divs... The odd thing is that the other menu item that extends does work and the whole thing works in firefox. Firebug reports uncaught exception: [Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMHTMLLIElement.replaceChild]" nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)" location: "JS frame :: http://www.recruitdonors.com/menu.js :: initMenu :: line 78" data: no] That is function initMenu(){ var menus, menu, text, a, i; menus = getChildrenByElement(document.getElementById("menu")); for(i = 0; i < menus.length; i++){ menu = menus[i]; text = getFirstChildByText(menu); a = document.createElement("a"); Line 78->>menu.replaceChild(a, text); a.appendChild(text); a.href = "#"; a.onclick = showMenu; a.onfocus = function(){this.blur()}; } Any input greatly appreciated including "debugging software" recommendations, techniques, a solution, ect. Thank you. Link to comment https://forums.phpfreaks.com/topic/125642-solved-extending-menu-script/ Share on other sites More sharing options...
web_loone_08 Posted September 25, 2008 Share Posted September 25, 2008 In IE (no problems in Firefox) the menu mostly works but the menu selection -OFFICE SUPPLIES- does not work. i tested it in IE7 - looks like it works fine to me Link to comment https://forums.phpfreaks.com/topic/125642-solved-extending-menu-script/#findComment-650088 Share on other sites More sharing options...
Brian W Posted September 25, 2008 Author Share Posted September 25, 2008 lol, I fixed it. Sorry, i'll say solved. BTW, it was a F***ing space, as in white space between a word and </a>... no kidding you. Thats what caused the problem. Not js, not my php, not even a good excuse for an error. I hate js, love what I can do with it. Thanks anyways though. Appreciate you coming back and looking at it for me. Link to comment https://forums.phpfreaks.com/topic/125642-solved-extending-menu-script/#findComment-650096 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.