script for menu

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • natty

    script for menu

    I have been trying to edit a script for a drop down type menu. the
    script is working as the sub menus flash up when i hover over the
    title links, but they are appearing in the top left hand corner and
    i'm not sure how to make them appear underneath. I have a feeling it
    might be to do with the amount of space in my frames, as i have two
    frames, one 20% where the script is loading and another 80% for my
    main content, so the 20% is where my navigation wants to be. Is there
    a way of getting round this? the script is below , thanks for any
    help!


    // Modify following four lines to customize your menu
    var tdColor="#FFFFF F"; // menu item text color
    var tdBgColor="#00A EED"; // menu item background color
    var hlColor="#FFFFF F"; // highlight text color
    var hlBgColor="#00A EED"; // highlight background color
    // After change, modify same values in your DropDown.css file

    ////////////////////DO NOT MODIFY BELOW HERE//////////////////////
    var md=250;
    var ti=-1;
    var oTd=new Object;
    oTd=null;

    function doMenu(td){
    clearTimeout(ti );
    td.style.backgr oundColor=hlBgC olor;
    td.style.color= hlColor;
    var i;
    var sT="";
    var tda=new Array();
    tda=td.id.split ("_");
    if(oTd!=null){
    var tdo=new Array();
    tdo=oTd.id.spli t("_");
    for(i=1;i<tdo.l ength;i++){
    sT+="_"+tdo[i];
    if(tdo[i]!=tda[i]){
    document.getEle mentById("td"+s T).style.backgr oundColor=tdBgC olor;
    document.getEle mentById("td"+s T).style.color= tdColor;
    if(document.get ElementById("tb l"+sT)!=null )
    document.getEle mentById("tbl"+ sT).style.visib ility="hidden";
    }
    }
    }
    oTd=td;
    sT="tbl";
    for(i=1;i<tda.l ength;i++)
    sT+="_"+tda[i];
    if(document.get ElementById(sT) !=null)
    document.getEle mentById(sT).st yle.visibility= "visible";

    }

    function clearMenu(){
    if(oTd!=null){
    var tdo=new Array();
    tdo=oTd.id.spli t("_");
    var sT="";
    for(var i=1;i<tdo.lengt h;i++){
    sT+="_"+tdo[i];
    document.getEle mentById("td"+s T).style.backgr oundColor=tdBgC olor;
    document.getEle mentById("td"+s T).style.color= tdColor;
    if(document.get ElementById("tb l"+sT)!=null )
    document.getEle mentById("tbl"+ sT).style.visib ility="hidden";
    }
    oTd=null;
    }
    }

    function runMenu(strURL) {
    location.href=s trURL;
    }

    var tt="";
    var sT="";
    var pT=new Array();
    var tA=new Array();

    function getCoord(st){
    tA=st.split("_" );
    if(tA.length>2) {
    tA=tA.slice(0,-1);
    tt=tA.join("_") ;
    return (document.getEl ementById("tbl" +tt).offsetTop+ document.getEle mentById("td"+s t).offsetTop)+" px;left:"+
    (document.getEl ementById("tbl" +tt).offsetLeft +document.getEl ementById("td"+ st).offsetWidth )+"px\">";
    }
    return (document.getEl ementById("main menu").offsetTo p+document.getE lementById("td" +st).offsetHeig ht)+"px;left:"+
    (document.getEl ementById("main menu").offsetLe ft+document.get ElementById("td "+st).offsetLef t)+"px\">";
    }

    var sH="<table class=\"menu\" id=\"mainmenu\" cellspacing=\"0 \"><tr>";
    var p=0;
    var j=0;
    while(eval("typ eof(td_"+ ++j +")!=\"undefine d\"")){
    sH+="<td id=\"td_"+j+"\" onmouseover=\"d oMenu(this)\"
    onmouseout=\"ti =setTimeout('cl earMenu()',md)\ "";
    sH+=(eval("type of(url_"+j+")!= \"undefined\"") )?"
    onclick=\"runMe nu('"+eval("url _"+j)+"')\">":" >";
    sH+=eval("td_"+ j)+"</td>";
    if (eval("typeof(t d_"+j+"_1)!=\"u ndefined\""))
    pT[p++]="_"+j;
    }
    sH+="</tr></table>";
    document.write( sH);
    for(var q=0;typeof(pT[q])!="undefined"; q++){
    sT=pT[q];
    sH="";
    j=0;
    sH+="<table class=\"menu\" id=\"tbl"+sT+"\ " cellspacing=\"0 \"
    style=\"top:"+g etCoord(sT);
    while (eval("typeof(t d"+sT+"_"+ ++j +")!=\"undefine d\"")){
    sH+="<tr><td id=\"td"+sT+"_" +j+"\" onmouseover=\"d oMenu(this)\"
    onmouseout=\"ti =setTimeout('cl earMenu()',md)\ "";
    sH+=(eval("type of(url"+sT+"_"+ j+")!=\"undefin ed\""))?"
    onclick=\"runMe nu('"+eval("url "+sT+"_"+j)+"') \">":">";
    sH+=eval("td"+s T+"_"+j)+"</td></tr>";
    if (eval("typeof(t d"+sT+"_"+j+"_1 )!=\"undefined\ ""))
    pT[p++]=sT+"_"+j;
    }
    sH+="</table>";
    document.write( sH);
    }
    document.getEle mentById("mainm enu").style.vis ibility="visibl e";
  • Bas Cost Budde

    #2
    Re: script for menu

    Forgive me for saying possibly stupid things, I'm a seasoned programmer
    but have only recently taken on Javascript.

    natty wrote:
    [color=blue]
    > I have been trying to edit a script for a drop down type menu. the
    > script is working as the sub menus flash up when i hover over the
    > title links, but they are appearing in the top left hand corner[/color]

    That makes me feel they are positioned absolutely, but the coordinates
    don't get set (correctly).

    When I try to read the script, I see getCoord() calls in a STYLE
    attribute. That is a place to look into.

    Are you sure you are using the browser for which the script was defined?

    Are you interested in using the code I wrote to display menus?
    [color=blue]
    > I have a feeling it
    > might be to do with the amount of space in my frames,[/color]

    I feel that is a less likely cause, but then again, I haven't completely
    understood the script.

    --
    Bas Cost Budde

    but the domain is nl

    Comment

    • natty

      #3
      Re: script for menu

      any help with any menu codes would be very useful thanks, i am still
      baffled on the code

      Bas Cost Budde <bas@heuveltop. org> wrote in message news:<c0dqsj$kd l$4@news2.solco n.nl>...[color=blue]
      > Forgive me for saying possibly stupid things, I'm a seasoned programmer
      > but have only recently taken on Javascript.
      >
      > natty wrote:
      >[color=green]
      > > I have been trying to edit a script for a drop down type menu. the
      > > script is working as the sub menus flash up when i hover over the
      > > title links, but they are appearing in the top left hand corner[/color]
      >
      > That makes me feel they are positioned absolutely, but the coordinates
      > don't get set (correctly).
      >
      > When I try to read the script, I see getCoord() calls in a STYLE
      > attribute. That is a place to look into.
      >
      > Are you sure you are using the browser for which the script was defined?
      >
      > Are you interested in using the code I wrote to display menus?
      >[color=green]
      > > I have a feeling it
      > > might be to do with the amount of space in my frames,[/color]
      >
      > I feel that is a less likely cause, but then again, I haven't completely
      > understood the script.[/color]

      Comment

      • kaeli

        #4
        Re: script for menu

        In article <1876319f.04021 20728.47963d54@ posting.google. com>,
        haribo_starmix@ hotmail.com enlightened us with...[color=blue]
        > any help with any menu codes would be very useful thanks, i am still
        > baffled on the code
        >[/color]

        I use HVMenu from http://www.dynamicdrive.com
        I like it and it works well with my framed site, too.

        --
        --
        ~kaeli~
        God was my co-pilot... but then we crashed in the mountains
        and I had to eat him.



        Comment

        • Bas Cost Budde

          #5
          Re: script for menu

          natty wrote:
          [color=blue]
          > any help with any menu codes would be very useful thanks, i am still
          > baffled on the code[/color]

          Remind me by mail if you don't get normal responses (my approach is not
          necessarily less complex).

          --
          Bas Cost Budde

          but the domain is nl

          Comment

          Working...