PDA

View Full Version : Urban Gray Accordion Menu with fetched content



liorshm
02-10-2013, 05:16 PM
hi


im trying to use the Accordion Menu Urban Gray Accordion Menu
http://www.dynamicdrive.com/dynamicindex17/ddaccordionmenu-urban.htm

only problem is im fetching the contents of it via java script from my right menu
fore some reason i cant get it to work

here is my page
244473.showenter.com/


this is my java script code





<script>

window.onload = function () {
var itemsdiv = document.getElementById("MenuBar1").getElementsByTagName("div");
var itemsul = document.getElementById("MenuBar1").getElementsByTagName("ul");
var itemsa = document.getElementById("MenuBar1").getElementsByTagName("a");
var itemli = document.getElementById("MenuBar1").getElementsByTagName("li");


for (var i = 0; i < itemsdiv.length; i++)
document.getElementById("MenuBar1").getElementsByTagName("div").className = itemsdiv[i].className = "headerbar";

for (var i = 0; i < itemsul.length; i++)
document.getElementById("MenuBar1").getElementsByTagName("ul").className = itemsul[i].className = "submenu";

for (var i = 0; i < itemsa.length; i++)
document.getElementById("MenuBar1").getElementsByTagName("a").className = itemsa[i].className = "";

for (var i = 0; i < itemsa.length; i++)
document.getElementById("MenuBar1").getElementsByTagName("a").tabIndex = itemsa[i].tabIndex = "";

for (var i = 0; i < itemli.length; i++)
document.getElementById("MenuBar1").getElementsByTagName("a").id = itemli[i].id = "";



var list = document.getElementById("MenuBar1");
var items = list.getElementsByTagName("ul");
for (var i = 0, size = items.length; i < size; i++) {
document.getElementById("lior").innerHTML += items[i].parentNode.innerHTML;
}
}</script>

<div id="lior" class="urbangreymenu"></div>


could anyone help me figuring out whats wrong

ddadmin
02-10-2013, 08:18 PM
The validity of your right menu structure wise aside, the main issue with the approach you're using to pull the menu's contents into the Accordion Menu is that you're using window.onload to do this. The Accordion menu is initialized before the window loads, so by the time the contents is pulled in, it's too late already. Regardless, a much cleaner approach is just to put the contents of your right menu in an external file (ie: menu.htm), and dynamically include it for both the right menu and Accordion Menu contents on the page. Is your page SSI enabled (http://www.javascriptkit.com/howto/ssi.shtml)?

liorshm
02-10-2013, 08:57 PM
im aware that its not the best way to do this, unfortunately i don't have any other option.
is there any other way i can postpone the initialztion of the The Accordion menu