Navigationsmenü umbauen

Hi,

bin jetzt einen Schritt weiter. Aber ich möchte bei einem mouseout ein Timeout haben. Leider funktioniert es weder so wie ich es im Moment habe

Code:
var temp, temp2, cookieArray, cookieArray2, cookieCount;

// The required pictures.
var menuClose;
var menuOpen;
var menuPage;

/**
 * Creates the relative pathes to the pictures.
 */
function createPics() {
  
  var relativePath = './';
  
  var path = window.location.pathname;
  var tokens = path.split('/');

  for (var i = (tokens.length - 3); i > 0; i--) {
    relativePath += '../';
  }
  
  menuOpen = relativePath + 'images/menu/plus.gif';
  menuClose = relativePath + 'images/menu/minus.gif';
  menuPage = relativePath + 'images/menu/page.gif';
}

function initiate(){
  
  // Creates the relative pathes to the pictures.
  createPics();
  
  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("menu");

  for(var o = 0; o < temp.getElementsByTagName("li").length; o++) {

    var li_elem = temp.getElementsByTagName("li")[o];

    if(li_elem.getElementsByTagName("ul").length > 0){
      
      li_elem.style.cursor = 'default';
      
        li_elem.onmouseover = function() {
		  show(this);
		}
		li_elem.onmouseout = function() {
		  // ---------------> hier <--------------------
		  setTimeout('', 1000);
		  hide(this);
        }

      temp2 = document.createElement("span");
      temp2.className = "symbols";
      temp2.style.backgroundImage = (cookieArray.length > 0) ? ((cookieArray[cookieCount] == "true") ? "url(" + menuClose + ")" : "url(" + menuOpen + ")") : "url(" + menuOpen + ")";
      //temp2.style.cursor = 'pointer';
      
      temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild)

      temp.getElementsByTagName("li")[o].getElementsByTagName("ul")[0].style.display = "none";

      if(cookieArray[cookieCount] == "true"){
        showhide(temp.getElementsByTagName("li")[o]);
      }

      cookieCount++;

    }
    else{
      temp2 = document.createElement("span");
      temp2.className = "symbols";
      temp2.style.backgroundImage = "url(" + menuPage + ")";
      temp.getElementsByTagName("li")[o].insertBefore(temp2, temp.getElementsByTagName("li")[o].firstChild);
    }

  }

}

function show(el) {
  el.getElementsByTagName("ul")[0].style.display = "block";
  el.getElementsByTagName("span")[0].style.backgroundImage = "url(" + menuOpen + ")";
}

function hide(el) {
  el.getElementsByTagName("ul")[0].style.display = "none";
  el.getElementsByTagName("span")[0].style.backgroundImage = "url(" + menuClose + ")";
}

function showhide(el) {
  el.getElementsByTagName("ul")[0].style.display = (el.getElementsByTagName("ul")[0].style.display == "block") ? "none" : "block";
  el.getElementsByTagName("span")[0].style.backgroundImage = (el.getElementsByTagName("ul")[0].style.display == "block") ? "url(" + menuClose + ")" : "url(" + menuOpen + ")";
}


/*
function writeCookie(){                // Runs through the menu and puts the "states" of each nested list into an array, the array is then joined together and assigned to a cookie.

  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();

}
*/

noch so

Code:
li_elem.onmouseout = function() {
		  // ---------------> hier <--------------------
		  setTimeout('hide(' + this + ')', 1000);
        }

Wäre für einen Hinweis dankbar.

Gruß

Romsl
 

Neue Beiträge

Zurück