⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmlmenuscript.js

📁 linux 内核调试.rar linux 内核调试.rar
💻 JS
字号:
var currentSpanElement    = "";      //Needed to track current span element
var menuArray        = new Array();  //Tracks what divs are showing so it knows what to hide when a new span is clicked
var onTextColor        = "#FFFFFF";  //Text color with mouseover
var offTextColor      = "#ffffff";  //Text color with NO mouseover
var onCellColor        = "#9D9846";  //Span color with mouseover
var offCellColor      = "#746D2D";  //Span color with nomouseover
var onBackgroundColor    = "#9D9846";
var offBackgroundColor    = "#746D2D";
var onTitleColor      = "#ffffff";
var offTitleColor      = "#ffffff";
var offsetMenuX        = 110;      //X Distance new menu will be from parent menu
var offsetMenuY        = 0;      //Y Distance increase of new menu compared to parent span
var startDistanceX      = 0;//-10;      //Sets how far off onMouseOver start element we should go
var startDistanceY      = 0;//5;      //Sets how far off onMouseOver start element we should go
var menuOn          = false;    //Only one set of menus can be displayed at once
var started          = false;    //Used to track if we just started the menus
var clickStart        = true;      //Allow an onClick event to start the menu or not here
var clickX          = -1;      //Location X of event to start menu
var clickY          = 118;      //Location Y of event to start menu
var selectCount        = 0;
var select          = "";
var appletCount        = 0;      //If we have applets, track the # so we can temporarily hide them
var applets          = "";      //Tracks the document.all.tags("applet") collection so we can reference it once rather than twice
//解决ie5被遮挡问题
var bodyHtml        ="";
bodyHtml+="<!doctype html public \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
bodyHtml+="<html><head><title></title>\n";
bodyHtml+="<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">\n";
bodyHtml+="<LINK href=\"js/menuStyle.css\" type=\"text/css\" rel=\"STYLESHEET\" />\n";
bodyHtml+="<SCRIPT LANGUAGE=\"JavaScript\">\n";
bodyHtml+="function checkBrowser(){\n";
bodyHtml+="  navigator.appVersion.search(/(\\(\\w+;) (\\w+) (\\d+)(\\.\\d)*/gi)\n";
bodyHtml+="  return RegExp.$3\n";
bodyHtml+="}\n";
bodyHtml+="function stopError() {\n";
bodyHtml+="return true;\n";
bodyHtml+="}\n";
bodyHtml+="window.onerror = stopError;\n";
bodyHtml+="\n";
bodyHtml+="</SCRIPT>\n";
bodyHtml+="</style></head><body leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" bgcolor="+offCellColor+">";
var menuHtmlArray      = new Array();  //保存<div class=clsMenu id=menu_6 data=""></div>里html内容的数组

//menu = menu to display,thisItem=coordinates of item to use,level=current depth of menus
function startIt(menu,thisItem,level) {
  changColor(thisItem,menu);
  //if (menuOn == true) {
    window.event.cancelBubble = true;
    hideAllDivs();
  //  return;                        //Only allow one menu to be activated at a time
  //} else {
    select = document.all.tags("select");
    selectCount = select.length;
    if (selectCount > 0) {
      for (i=0;i<selectCount;i++) {
        //select.item(i).style.visibility = "hidden";
      }
    }
    applets = document.all.tags("applet");
    appletCount = applets.length;
    if (appletCount > 0) {
      for (i=0;i<appletCount;i++) {
        applets.item(i).style.visibility = "hidden";
      }
    }
    menuOn = true;
    started = true;                    //Lets us know we're coming in for the 1st time
    clickX = document.body.scrollLeft+event.clientX-event.offsetX-10;//event.clientX;
    clickY = event.clientY-event.offsetY+24;
    if (clickStart) window.event.cancelBubble = true;
    stateChange(menu,thisItem,level);
  //}
}

function stateChange(menu,thisItem,level) {                  //menu = menu to display,thisItem=name of span item to use,level=current depth of menus

  if (currentSpanElement != thisItem.id && started != true) {              //Only hit this if they changed span elements
    if (currentSpanElement == "") currentSpanElement = thisItem.id;  //Used 1st time through only

    eItemOld = eval("document.all('" + currentSpanElement + "')");
    eItemNew = eval("document.all('" + thisItem.id + "')");
    eParent = eItemNew.parentElement;
    eParent.style.background = offCellColor;            //Must set DIV background color or it will be transparent by default

    //Turn off whatever span was turned on
    eItemOld.style.background = offCellColor;
    eItemOld.style.color = offTextColor;
    //Turn on new span
    eItemNew.style.background = onCellColor;
    eItemNew.style.color = onTextColor;

    currentSpanElement = thisItem.id;          //Track where the last mouseover came from
  }

  if (menu != "") {
    eMenu = eval("document.all('" + menu + "')");
    eItem = eval("document.all('" + thisItem.id + "')");        //Used for x,y coordinates

    //ie5下拉菜单解决遮挡问题
    if(checkBrowser()==5&&level==0){
    if(typeof(menuHtmlArray[eMenu.data])=="undefined"){
      menuHtmlArray[eMenu.data]=bodyHtml+eMenu.innerHTML+"</body></html>";//把原来的html放入数组
    }else{
        eMenu.innerHTML='';
    }
    eMenu.style.height=eMenu.childNodes.length*"35";
    if(eMenu.style.height=="0px"){
      eMenu.style.height="210px";
    }
    eMenu.innerHTML="<iframe name=if"+eMenu.data+" width=100% height=100% scrolling=no frameborder=0></iframe>";
    eval("if"+eMenu.data+".document.write(menuHtmlArray[eMenu.data])");
    }
    try{
    eMenu.id
    }catch(e){
    return;
    }
    //}
    //ie5下拉菜单解决遮挡问题

    hideDiv(level);
    menuArray[menuArray.length] = menu;                  //Tracks open menus

    var positionX =  eItem.parentElement.offsetLeft + offsetMenuX //+ document.body.scrollLeft;
    var positionY =   eItem.parentElement.offsetTop + eItem.offsetTop + offsetMenuY //+ document.body.scrollTop;
    if (started) {
      positionX =  clickX + startDistanceX  + document.body.scrollLeft  //eItem.offsetLeft + startDistanceX;
      positionY =  clickY + startDistanceY  + document.body.scrollTop  //eItem.offsetTop + startDistanceY;
    }
    //If screen isn't wide enough to fit menu, bump menu back to the left some
    if ((positionX + eMenu.offsetWidth) >= document.body.clientWidth) {
      positionX -= (eMenu.offsetWidth * 1.3);
      positionY += 15;
    }
    //If the menu is too far to the left to display, bump it to the right some
    if ((positionX + eMenu.offsetWidth) <= eMenu.offsetWidth) {
      positionX += (eMenu.offsetWidth * 1.3);
    }
    //If the menu is too far down, bump the menu up to the bottom equals the body clientHeight property
    if ((positionY + eMenu.offsetHeight) >= document.body.clientHeight) {
      if (started != true) positionY = document.body.clientHeight - eMenu.offsetHeight;
    }

    eMenu.style.left = positionX+6;
    eMenu.style.top = positionY;

    //eMenu.style.zIndex = level;                  //Only use this if we don't reverse the arrays in the ASP/XML Script
    eMenu.style.display="block";

  }

  started = false;                        //After 1st menu, turn of started variable
}

function hideDiv(currentLevel) {
    for (var i=currentLevel;i<menuArray.length;i++) {
      var arrayString = new String(menuArray[i]);
      if (arrayString == "undefined") continue;
      eval("document.all('" + menuArray[i] + "').style.display='none'");
    }
      menuArray.length = currentLevel;
}

function hideAllDivs() {
  if (menuOn == true) {    //Don't loop through document elements if they clicked a hyperlink since it wastes time
    for (var i=0;i<menuArray.length;i++) {
      var arrayString = new String(menuArray[i]);
      if (arrayString == "undefined") continue;
      document.all(menuArray[i]).style.display = "none";
      document.all(menuArray[i]).style.left = 0;
      document.all(menuArray[i]).style.top = 0;

    }
    if (currentSpanElement != "") {          //No currentSpanElement if they haven't mousedOver any span element
      eItem = eval("document.all('" + currentSpanElement + "')");
      eItem.style.background = offCellColor;    //Ensure current span's color is changed back to "off" color
      eItem.style.color = offTextColor;    //Ensure current span's text color is changed back to "off" color
      menuArray = new Array();
      currentSpanElement = "";
    }
    if (selectCount > 0) {
      for (i=0;i<selectCount;i++) {
        select.item(i).style.visibility = "visible";
      }
      selectCount = 0;
      select = "";
    }
    if (appletCount > 0) {
      for (i=0;i<appletCount;i++) {
        applets.item(i).style.visibility = "visible";
      }
      appletCount = 0;
      applets = "";
    }
  }
  menuOn = false;                //Menus off, so set this to false


}
function changColor(thisItem,id){

  if((id+"").indexOf("menu_")==0){
  id=id.substring(5);
  }
  /*
  if(thisItem.style.background==onBackgroundColor){
  thisItem.style.background=offBackgroundColor;
  thisItem.style.color=offTitleColor;
  }else{
  thisItem.style.background=onBackgroundColor;
  thisItem.style.color=onTitleColor;
  }
  */
}
//模块跳转接口
//如果有新的模块加入,修改下面的if判断
function gotoMenuUrl(datasource,href,url,target){
  //alert(datasource+"\n"+href+"\n"+url+"\n"+target)
  var f="";
  /*
  if(datasource=="article/main.asp"){
    f="/article_list.asp"
  }else if(datasource=="articleOne/main.asp"){
    f="/article_one.asp"
  }else if(datasource=="#nav"){
    f="/websitenav.asp"
  }else if(datasource=="#photo"){
    f="/photo_list.asp"
  }else if (datasource=="0"){
    f=""
  }else{
    f=""
  }
  */
  if(datasource!=""){
    f=datasource;
  }
  if (href!=""){
    f=href
  }
  if (f==""){
    return;
  }
    if (target=="_self"){
    try{
      top.mainFrame.document.location=f+url
    }catch(e){
    top.location=f+url
    }
  }else{
    window.open(f+url)
  }
}

document.onclick = hideAllDivs;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -