Please take a look http://www.dalibor-sojic.info/gyokomura/ with Mozilla Firefox and with IE. In Mozilla work's OK, in IE do not work. Explanation: There is some items (in the menu) which have submenu. I'm using JS to open/close, write cookie (which node is open/close). Please take a look, and give me a solution (or hint). The js is located on http://www.dalibor-sojic.info/gyokomura/js.js Here is part of js (just functions which I'm using for open/close) var temp, temp2, cookieArray, cookieArray2, cookieCount; function initiate(){ cookieCount=0; if(document.cookie){ cookieArray=document.cookie.split(";"); cookieArray2=new Array(); for(i in cookieArray){ cookieArray2[cookieArray[i].split("=")[0].replace(/ /g,"")]=cookieArray[i].split("=")[1].replace(/ /g,""); } } cookieArray=(document.cookie.indexOf("state=")>=0)?cookieArray2["state"].split(","):new Array(); temp=document.getElementById("main-menu"); for(var o=0;o<temp.getElementsByTagName("li").length;o++){ if(temp.getElementsByTagName("li")[o].getElementsByTagName("ul").length>0){ temp.getElementsByTagName("li")[o].getElementsByTagName("ul")[0].style.display = "none"; if(cookieArray[cookieCount]=="true"){ showhide(temp.getElementsByTagName("li")[o]); } cookieCount++; } else{ } } } function showhide(el){ el.getElementsByTagName("ul")[0].style.display=(el.getElementsByTagName("ul")[0].style.display=="block")?"none":"block"; } function writeCookie(){ cookieArray=new Array() for(var q=0;q<temp.getElementsByTagName("li").length;q++){ if(temp.getElementsByTagName("li")[q].childNodes.length>0){ if(temp.getElementsByTagName("li")[q].childNodes[0].nodeName=="SPAN" && temp.getElementsByTagName("li")[q].getElementsByTagName("ul").length>0){ cookieArray[cookieArray.length]=(temp.getElementsByTagName("li")[q].getElementsByTagName("ul")[0].style.display=="block"); } } } document.cookie="state="+cookieArray.join(",")+";expires="+new Date(new Date().getTime() + 365*24*60*60*1000).toGMTString(); } function hide(item) { document.getElementById(item).style.display='none'; } function show(item) { document.getElementById(item).style.display='auto'; } function hideAll(what) { var nodovi = new Array('kokino','adam','vital','beyond','mixed','aprilia','chillout'); for (i=0; i<=nodovi.length-1; i++) { item = nodovi[i]; if (what != item) { document.getElementById(item).style.display='none'; } } } function hideMain() { var nodovi = new Array('projects','curriculum'); for (i=0; i<=nodovi.length-1; i++) { item = nodovi[i]; document.getElementById(item).style.display='none'; } } Code (markup):
I would be lad to help, but i don't use windows, so I have no access to IE. can You describe the problem in more detail?
Well... Try the site with FF. It is OK. When you will click on Projects, submenu will expand. Here is the part of the html code <span onclick="setClass('main-menu', this, 'clicked'); hideMain();showhide(this.parentNode);writeCookie();">Project Samples</span> Code (markup): The "main" function is "showhide(this.parentNode)" which do not work in IE. In IE if you click on Project Samples, nothing will happend.
well, I found your bug, on the hideMain function, replace item = nodovi; by var item = nodovi; But i have another question for you, do you really need to include so many script files?
Well, Do I have to include so many script files? I'm including 5 script files. (4 are for gallery, 1 is my js.js). Currently, there is 2 includes that I do not need. About the error. Still don't work. I think that the problem is: <li><span onclick="setClass('main-menu', this, 'clicked'); hideMain();[B]showhide(this.parentNode)[/B];writeCookie();">Project Samples</span> <ul id="projects"> Code (markup): js.js function showhide(el){ el.getElementsByTagName("ul")[0].style.display=(el.getElementsByTagName("ul")[0].style.display=="block")?"none":"block"; } Code (markup):
I'm pretty sure that all those scripts are interfering with each other. Take a look at this testing page I've put online: www.hrcerqueira.com/mfiles/gyokomura.html Code (markup): It's working, why's that???
http://www.dalibor-sojic.info/gyokomura - working OK http://www.gyokomura.com - same code, do not working, I get error Error: cookieArray[i].split is not a function Source File: http://www.gyokomura.com/js.js Line: 40 Code (markup):
The problem is after clicking on some link. On "original" site (http://gyokomura.com) the menu on opened page is closed, and on "test" (http://www.dalibor-sojic.info/gyokomura) is opened. The problem is in INITIATE() function. The menu working like this: On click, cookie is saved on client browser. After opening the page, I call js function INITIATE, which "parse" cookie and colapse/expand menu.