Results 1 to 2 of 2

Thread: Switch menu

  1. #1
    Join Date
    Mar 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Switch menu

    dear members,

    I have a switch menu on my site . How can i let it start with firts menu down. (visible)


    example

    <style type="text/css">
    .menutitle{
    cursorointer;
    margin-bottom: 5px;
    background-color:#000080;
    color:#000000;
    width:200px;
    padding:2px;
    text-align:center;
    font-weight:bold;
    /*/*/border:1px solid #000000;/* */}
    .submenu{margin-bottom: 0.5em;}
    </style>

    <script type="text/javascript">



    var persistmenu="yes"
    var persisttype="sitewide"

    if (document.getElementById){
    document.write('<style type="text/css">\n')
    document.write('.submenu{display: none;}\n')
    document.write('</style>\n')
    }

    function SwitchMenu(obj){
    if(document.getElementById){
    var el = document.getElementById(obj);
    var ar = document.getElementById("masterdiv").getElementsByTagName("span");
    if(el.style.display != "block"){
    for (var i=0; i<ar.length; i++){
    if (ar[i].className=="submenu")
    ar[i].style.display = "none";
    }
    el.style.display = "block";
    }else{
    el.style.display = "none";
    }
    }
    }

    function get_cookie(Name) {
    var search = Name + "="
    var returnvalue = "";
    if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) {
    offset += search.length
    end = document.cookie.indexOf(";", offset);
    if (end == -1) end = document.cookie.length;
    returnvalue=unescape(document.cookie.substring(offset, end))
    }
    }
    return returnvalue;
    }

    function onloadfunction(){
    if (persistmenu=="yes"){
    var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
    var cookievalue=get_cookie(cookiename)
    if (cookievalue!="")
    document.getElementById(cookievalue).style.display="block"
    }
    }

    function savemenustate(){
    var inc=1, blockid=""
    while (document.getElementById("sub"+inc)){
    if (document.getElementById("sub"+inc).style.display=="block"){
    blockid="sub"+inc
    break
    }
    inc++
    }
    var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
    var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
    document.cookie=cookiename+"="+cookievalue
    }

    if (window.addEventListener)
    window.addEventListener("load", onloadfunction, false)
    else if (window.attachEvent)
    window.attachEvent("onload", onloadfunction)
    else if (document.getElementById)
    window.onload=onloadfunction

    if (persistmenu=="yes" && document.getElementById)
    window.onunload=savemenustate

    </script>

    </head>

    <body bgcolor="#BAD405" marginwidth="1280" marginheight="768">


    <font size="2" face="Comic Sans MS">

    <tr>
    <td width="88%" height="100%" bordercolor="#000000" valign="top" bgcolor="#BAD405">

    <td width="23%" height="0" bordercolor="#BAD405">
    </font>
    <font face="Comic Sans MS" <font size="2"></font><div id="masterdiv">


    <div class="menutitle" onclick="SwitchMenu('sub1')" style="width: 175px; height: 29px">
    <p style="text-align: left">
    <font color="#ffffff" face="Comic Sans MS">Foto Archief</font></div>
    <p align="left"><span class="submenu" id="sub1">
    </font>
    <font size="2" face="Comic Sans MS">

    <font color="#0000FF">

    - </font> <a target="_blank" href="2010%20Koken%20maart/index.html">Koken maart 2010</a><font color="#0000FF"><br>

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    Code:
    <body  marginwidth="1280" marginheight="768" onload="SwitchMenu('sub1');">
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •