Results 1 to 7 of 7

Thread: Anylink Dropdown Menu + Wordpress

  1. #1
    Join Date
    Jun 2008
    Posts
    3
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Anylink Dropdown Menu + Wordpress

    1) Script Title: Anylink Dropdown Menu

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

    3) Describe problem: My wordpress blog is located at http://kevmarl.com

    I had the menu working fine with two dropdown menus, however when I added a third menu it failed.

    Here is my header code:
    <div id="masthead">
    <h1><a href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a></h1>
    <h3><?php bloginfo('description'); ?></h3>
    </div>

    <ul id="nav">
    <style type="text/css">

    #dropmenudiv{
    position:absolute;
    border:1px solid black;
    border-bottom-width: 0;
    font:bold 12px verdana;
    line-height:18px;
    z-index:100;
    }

    #dropmenudiv a{
    width: 100%;
    display: block;
    text-indent: 3px;
    border-bottom: 1px solid black;
    padding: 1px 0;
    text-decoration: none;
    font-weight: bold;
    }

    #dropmenudiv a:hover{ /*hover background color*/background-color: white;}

    </style>

    <script type="text/javascript">

    /***********************************************
    * AnyLink Drop Down Menu- © Dynamic Drive (www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit http://www.dynamicdrive.com/ for full source code
    ***********************************************/

    //Contents for menu 1
    var menu1=new Array()
    menu1[0]='<a href="http://kevmarl.com/kevin/">Kevin</a>'
    menu1[1]='<a href="http://kevmarl.com/marlain/">Marlain</a>'
    menu1[2]='<a href="http://kevmarl.com/rachele/">Rachele</a>'
    menu1[3]='<a href="http://kevmarl.com/travis/">Travis</a>'

    //Contents for menu 2
    var menu2=new Array()
    menu2[0]='<a href="http://kevmarl.com/category/youtube/">Youtube</a>'
    menu2[1]='<a href="http://kevmarl.com/category/television/">Television</a>'
    menu2[2]='<a href="http://kevmarl.com/category/family-video/">Family Videos</a>'
    menu2[3]='<a href="http://kevmarl.com/category/video/">All Videos</a>'

    //Contents for menu 3
    var menu2=new Array()
    menu3[0]='<a href="http://kevmarl.com/category/review/">Review</a>'

    var menuwidth='165px' //default menu width
    var menubgcolor='#fee5ac' //menu bgcolor
    var disappeardelay=250 //menu disappear speed onMouseout (in miliseconds)
    var hidemenu_onclick="yes" //hide menu when user clicks within menu?

    /////No further editting needed

    var ie4=document.all
    var ns6=document.getElementById&&!document.all

    if (ie4||ns6)
    document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

    function getposOffset(what, offsettype){
    var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
    var parentEl=what.offsetParent;
    while (parentEl!=null){
    totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
    parentEl=parentEl.offsetParent;
    }
    return totaloffset;
    }


    function showhide(obj, e, visible, hidden, menuwidth){
    if (ie4||ns6)
    dropmenuobj.style.left=dropmenuobj.style.top="-500px"
    if (menuwidth!=""){
    dropmenuobj.widthobj=dropmenuobj.style
    dropmenuobj.widthobj.width=menuwidth
    }
    if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
    obj.visibility=visible
    else if (e.type=="click")
    obj.visibility=hidden
    }

    function iecompattest(){
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
    }

    function clearbrowseredge(obj, whichedge){
    var edgeoffset=0
    if (whichedge=="rightedge"){
    var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
    dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
    if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
    edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
    }
    else{
    var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
    var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
    dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
    if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
    edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
    if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
    edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
    }
    }
    return edgeoffset
    }

    function populatemenu(what){
    if (ie4||ns6)
    dropmenuobj.innerHTML=what.join("")
    }


    function dropdownmenu(obj, e, menucontents, menuwidth){
    if (window.event) event.cancelBubble=true
    else if (e.stopPropagation) e.stopPropagation()
    clearhidemenu()
    dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
    populatemenu(menucontents)

    if (ie4||ns6){
    showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
    dropmenuobj.x=getposOffset(obj, "left")
    dropmenuobj.y=getposOffset(obj, "top")
    dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
    dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
    }

    return clickreturnvalue()
    }

    function clickreturnvalue(){
    if (ie4||ns6) return false
    else return true
    }

    function contains_ns6(a, b) {
    while (b.parentNode)
    if ((b = b.parentNode) == a)
    return true;
    return false;
    }

    function dynamichide(e){
    if (ie4&&!dropmenuobj.contains(e.toElement))
    delayhidemenu()
    else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
    delayhidemenu()
    }

    function hidemenu(e){
    if (typeof dropmenuobj!="undefined"){
    if (ie4||ns6)
    dropmenuobj.style.visibility="hidden"
    }
    }

    function delayhidemenu(){
    if (ie4||ns6)
    delayhide=setTimeout("hidemenu()",disappeardelay)
    }

    function clearhidemenu(){
    if (typeof delayhide!="undefined")
    clearTimeout(delayhide)
    }

    if (hidemenu_onclick=="yes")
    document.onclick=hidemenu

    </script>

    <li><a <?php if (is_home()) echo('class="current" '); ?>href="<?php bloginfo('url'); ?>">welcome</a></li>
    <li><a <?php if (is_page('kevin')) echo('class="current" '); ?>href="default.htm" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, menu1, '150px')" onMouseout="delayhidemenu()">about us</a></li>
    <li><a <?php if (is_page('video')) echo('class="current" '); ?>href="default2.htm" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, menu2, '150px')" onMouseout="delayhidemenu()">video</a></li>
    <li><a <?php if (is_page('review')) echo('class="current" '); ?>href="default3.htm" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, menu3, '150px')" onMouseout="delayhidemenu()">review</a></li>
    <li><a <?php if (is_page('photos')) echo('class="current" '); ?>href="<?php bloginfo('url'); ?>/category/photos/">photos</a></li>

    <li><a <?php if (is_page('downloads')) echo('class="current" '); ?>href="<?php bloginfo('url'); ?>/category/download/">downloads</a></li>
    <li><a <?php if (is_page('kevmarl.com')) echo('class="current" '); ?>href="<?php bloginfo('url'); ?>/private">private</a></li>
    <li><a <?php if (is_page('e-mail')) echo('class="current" '); ?>href="<?php bloginfo('url'); ?>/contact">e-mail</a></li>
    <li><a <?php if (is_page('blog')) echo('class="current" '); ?>href="<?php bloginfo('url'); ?>/blog">blog</a></li>
    <li class="rss"><a href="<?php bloginfo('rss2_url'); ?>">RSS</a></li>
    </ul>

  2. #2
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    See if changing the highlighted to 3 helps:
    Code:
    //Contents for menu 3
    var menu2=new Array()
    menu3[0]='<a href="http://kevmarl.com/category/review/">Review</a>'
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  3. The Following User Says Thank You to rangana For This Useful Post:

    kevmarl (06-14-2008)

  4. #3
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Yes, rangana is right, I'll explain why. You've already used the menu2 for a variable, and added menus to it. You can't create 2 of the same variables on the page, or something will mess up ussually, you need to keep adding to the end. menu1, menu2, menu3, menu4, menu5....
    Jeremy | jfein.net

  5. The Following User Says Thank You to Nile For This Useful Post:

    kevmarl (06-14-2008)

  6. #4
    Join Date
    Jun 2008
    Posts
    3
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the help...it was obvious once you pointed it out to me.
    My second problem I would like to fix is when you look at the dropdown menus at http://kevmarl.com, the dropdown menus are not centred with there respective headings, any advice in fixing this would be appreciated.

  7. #5
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Add margin-left:-40px; on dropmenudiv. Feel free to play with the units till you get your desired layout.
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  8. The Following User Says Thank You to rangana For This Useful Post:

    kevmarl (06-14-2008)

  9. #6
    Join Date
    Jun 2008
    Posts
    3
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Thanks for your help Rangana, it worked perfectly....

  10. #7
    Join Date
    Sep 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Looks good - but I was wondering - why does the WHITE hover effect only work in Firefox and not IE? If changed to "red" instead of "white" it works fine - but not with white?!?

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
  •