Подскажите пожалуйста со скриптом раскрывающегося меню

Автор seo-seo, 30-11-2011, 09:40:42

« назад - далее »

seo-seoTopic starter

Дело в том, что он у меня не работает в Опере, а в IE и Мозилле все норм.
Вот он:

<script>
<!--

  document.onmouseover = doDocumentOnMouseOver ;
  document.onmouseout = doDocumentOnMouseOut ;

  function doDocumentOnMouseOver() {
    var eSrc = window.event.srcElement ;
    if (eSrc.className == "item") {
      window.event.srcElement.className = "highlight";
    }
  }

  function doDocumentOnMouseOut() {
    var eSrc = window.event.srcElement ;
    if (eSrc.className == "highlight") {
      window.event.srcElement.className = "item";
    }
  }


var bV=parseInt(navigator.appVersion);
NS4=(document.layers) ? true : false;
IE4=((document.all)&&(bV>=4)) ? true : false;
DOM=(!document.layers && !document.all && bV>=4) ? true : false; // A hаck to guess if the browser supports the DOM
capable = (NS4 || IE4 || DOM) ? true : false;

function expandIt(){return}
function expandAll(){return}

isеxpanded = false;

function getIndex(el) {
  ind = null;
  for (i=0; i<document.layers.length; i++) {
    whichEl = document.layers[i];
    if (whichEl.id == el) {
      ind = i;
      break;
    }
  }
  return ind;
}

function arrange() {
  nextY = document.layers[firstInd].pageY + document.layers[firstInd].document.height;
  for (i=firstInd+1; i<document.layers.length; i++) {
    whichEl = document.layers[i];
    if (whichEl.visibility != "hide") {
      whichEl.pageY = nextY;
      nextY += whichEl.document.height;
    }
  }
}

function initIt(){
  if (NS4) {
    for (i=0; i<document.layers.length; i++) {
      whichEl = document.layers[i];
      if (whichEl.id.indexOf("Child") != -1) whichEl.visibility = "hide";
    }
    arrange();
  } else if(IE4) {
    tempColl = document.all.tags("DIV");
    for (i=0; i<tempColl.length; i++) {
      if (tempColl(i).className == "child") tempColl(i).style.display = "none";
    }
  } else if(DOM) {
    tempColl = document.getElementsByTagName("DIV");
    for (i=0; i<tempColl.length; i++) {
      if (tempColl(i).className == "child") tempColl(i).style.visibility = "hidden";
    }
  }
}

function expandIt(el) {
  if (!capable) return;
  if (IE4) {
    expandIE(el);
  } else if(NS4) {
    expandNS(el);
  } else if(DOM) {
    expandDOM(el);
  }
}

function expandIE(el) {
  whichEl = eval(el + "Child");

  //whichIm = event.srcElement;
        whichIm = eval(el+"Img");

  if (whichEl.style.display == "none") {
    whichEl.style.display = "block";
    whichIm.src = "index/minus.gif";
  }
  else {
    whichEl.style.display = "none";
    whichIm.src = "index/plus.gif";
  }
    window.event.cancelBubble = true ;
}

function expandNS(el) {
  whichEl = eval("document." + el + "Child");
  whichIm = eval("document." + el + "Parent.document.index['imEx']");
  if (whichEl.visibility == "hide") {
    whichEl.visibility = "show";
    whichIm.src = "index/minus.gif";
  }
  else {
    whichEl.visibility = "hide";
    whichIm.src = "index/plus.gif";
  }
  arrange();
}

function expandDOM(el) {

  whichEl = document.getElementById(el + "Child");
    whichIm = document.getElementById(el + "Img");

  if (whichEl.style.visibility != "visible") {
    whichEl.style.visibility = "visible";
    whichIm.src = "index/minus.gif";
  } else {
    whichEl.style.visibility = "hidden";
    whichIm.src = "index/plus.gif";
  }

}

function showAll() {
  for (i=firstInd; i<document.layers.length; i++) {
    whichEl = document.layers[i];
    whichEl.visibility = "show";
  }
}

function expandAll(isBot) {
  // Brian Birtles 7-Jun-00 : This fn might be unnecessary (for phpMyAdmin).
  // My changes are certainly untested.
  newSrc = (isеxpanded) ? "index/plus.gif" : "index/minus.gif";

  if (NS4) {
        // TR-02-01-99: Don't need that
        // document.index["imEx"].src = newSrc;
    for (i=firstInd; i<document.layers.length; i++) {
      whichEl = document.layers[i];
      if (whichEl.id.indexOf("Parent") != -1) {
        whichEl.document.index["imEx"].src = newSrc;
      }
      if (whichEl.id.indexOf("Child") != -1) {
        whichEl.visibility = (isеxpanded) ? "hide" : "show";
      }
    }

    arrange();
   if (isBot && isеxpanded) scrollTo(0,document.layers[firstInd].pageY);
  } else if(IE4) {
    divColl = document.all.tags("DIV");
    for (i=0; i<divColl.length; i++) {
      if (divColl(i).className == "child") {
        divColl(i).style.display = (isеxpanded) ? "none" : "block";
      }
    }
    imColl = document.index.item("imEx");
    for (i=0; i<imColl.length; i++) {
      imColl(i).src = newSrc;
    }
  } else if(DOM) {
    divColl = document.getElementsByTagName("DIV");
    for (i=0; i<divColl.length; i++) {
      if (divColl(i).className == "child") {
        divColl(i).style.visibility = (isеxpanded) ? "hidden" : "visible";
      }
    }
    imColl = document.getElementsByName("imEx");
    for (i=0; i<imColl.length; i++) {
      imColl(i).src = newSrc;
    }
  }

  isеxpanded = !isеxpanded;
}

with (document) {
  if(DOM) {
    var lstyle = "<style type='text/css'>";
    lstyle += ".child {font-family: Arial, Helvetica; color: #FFFFFF; text-decoration:none; visibility:hidden}";
    lstyle += ".parent {font-family:Arial,Helvetica;font-size:16px;text-decoration:none;}";
    lstyle += ".item { color: #006; text-decoration:none; font-size: 16px;}";
    lstyle += ".highlight { color: #FFFFFF; font-size: 13px;}";
    lstyle += ".heada {font-size:14px;font-family:Arial,Helvetica;color:#000;}";
    lstyle += "DIV { color:#FFFFFF; }";
    lstyle += "</style>";
    write(lstyle);
  } else {
    write("<style type='text/css'>");
    if (NS4) {
            write(".parent {font-family:Arial,Helvetica;color:#000;text-decoration:none;font-size:16px;position:absolute;margin-left:30px;visibility:hidden;}");
            write(".child {font-family:Arial,Helvetica;font-size:13px;position:absolute;visibility:hidden}");
            write(".item { color: darkblue; text-decoration:none;}");
            write(".regular {font-family: Arial,Helvetica; position:absolute; visibility:hidden}");
            write("DIV { color:white; }");
    } else if(IE4) {
            write(".child {font-family:Arial,Helvetica;font-size:13px;color:#666;text-decoration:none;display:none}");
            write(".parent {font-family:Arial,Helvetica;font-size:16px;text-decoration:none;}");
            write(".item { color: #FFFFFF; text-decoration:none; font-size: 13px;}");
            write(".highlight { color: #FFFFFF; font-size: 13px;}");
            write(".heada {font-size:14px;font-family:Arial,Helvetica;color:#000;}");
            write("DIV { color:white; }");
    }
    write("</style>");
  }
}

onload = initIt;
//-->
</script>

<div id="el2Parent" class="parent">&nbsp; <a class="item" href="javascript://" onClick="expandIt('el2'); return false;"><img name="imEx" SRC="index/plus.gif" border="0" alt="" width="9" height="9" ID="el2Img"></a>&nbsp;<a class="item" href="javascript://" onClick="expandIt('el2');">

<font class="heada">ССЫЛКА МЕНЮ</font></a></div>

<div ID="el2Child" CLASS="child">

Выпадающее меню

</div>


Буду премного благодарен  :)


Cergo

Лежит у меня на народе, заброшенная работа 2006 года.
http://gp722.narod.ru/index.html

Там использован скрипт transmenu
Может вам лучше воспользоваться им?
Он вроде кросбраузерный.
  •  



Гарик+