Results 1 to 4 of 4

Thread: Switch Menu - Default to an open menu

  1. #1
    Join Date
    Feb 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Switch Menu - Default to an open menu

    1) Script Title: Switch Menu

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...switchmenu.htm

    3) Describe problem: Hello, what i would like to have is that the first menu is defaulted to open when someone first gets to the menu. for instance on your demo, the "site menu" tab would automatically be open.

    Im using switch menu to display pricing http://www.urbantrackers.com/bedding...d=D&style_id=P
    and i would like for the first available menu (in this case comforter sets) to be open.

    Thank you,

    ~ Moe

  2. #2
    Join Date
    Feb 2007
    Location
    England
    Posts
    254
    Thanks
    0
    Thanked 5 Times in 5 Posts

    Default Just a tiny modification

    Just add

    Code:
    style="display:block;"
    to the sub section you want open when you start.


  3. #3
    Join Date
    Dec 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    you can do a style="display: block;" ... but if you use the persistent menu, then you will have two default menus open the next time you click on a page ...

    ... so I tweaked the code so now if the persistent cookie is empty it loads a default menu...

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

  4. #4
    Join Date
    Dec 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    there was a slight but... here is the corrected code

    Code:
    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"
    		} else {
    			// put your initial menu here
    			document.getElementById("sub1").style.display="block";
    		}
    	}
    }

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
  •