Results 1 to 2 of 2

Thread: AnyLink Vertical Drop Menu Modification?

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

    Default AnyLink Vertical Drop Menu Modification?

    Hello,
    I love the AnyLink drop menu script works great for static links. But I would like to modify it to accept dynamic links. For instance in the onMouseOver call to the menu scripts I would like to add another variable called myusername and have that myusername variable appended to the end of each of the menu array links. For instance


    <a href="#" onMouseover="dropdownmenu(this, event, menu1, '165px', 'myusername')" onMouseout="delayhidemenu()">myusername</a>


    then have the output link when clicked on go to
    http://www.mysite.com/usercheck.asp?...me=(myusername)

    this way I can have a list of users and send them to a dynamic page just for them

    user1 > http://www.mysite.com/usercheck.asp?username=user1
    user2 > http://www.mysite.com/usercheck.asp?username=user2
    user3 > http://www.mysite.com/usercheck.asp?username=user3

    if anyone can help me with this I would greatly appreciate it.

    Admin@badbadbiker.com

  2. #2
    Join Date
    Feb 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    i figured it out myself. here is how i did it...

    basically i created a new function to define the links which is the createmenulinks function.. then i pass a variable in the mouseover to the dropdownmenu function... i then modified the dropdownmenu function to call the createmenulinks function... so everytime someone mouses over it redefines the menu links array allowing me to create a dynamic link for each different username.......i hope you DD guys dont mind me modifying the script.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <style type="text/css">
    
    #dropmenudiv{
    position:absolute;
    background-color: #000000;
    border:1px solid #ff9900;
    border-bottom-width: 1;
    font:normal 10px Verdana;
    line-height:16px;
    z-index:100;
    }
    
    #dropmenudiv a{
    width: 100%;
    display: block;
    text-indent: 3px;
    border-bottom: 1px solid #000000;
    padding: 1px 0;
    text-decoration: none;
    font-weight: bold;
    }
    
    #dropmenudiv a:hover{ /*hover background color*/
    background-color: #333333;
    }
    
    </style>
    
    
    <script type="text/javascript">
    
    /***********************************************
    * AnyLink Vertical 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()
    createmenulinks('#')
    function createmenulinks(targetname)
    {
    menu1[0]='<a name="link0" href="action.asp?action=0&target=' + targetname + '">Scout Em</a>'
    menu1[1]='<a name="link1" href="action.asp?action=1&target=' + targetname + '">Fight Em</a>'
    menu1[2]='<a name="link2" href="action.asp?action=2&target=' + targetname + '">Rob Em</a>'
    menu1[3]='<a name="link3" href="action.asp?action=3&target=' + targetname + '">Kill Em</a>'
    menu1[4]='<a name="link4" href="action.asp?action=4&target=' + targetname + '">Send Message</a>'
    menu1[5]='<a name="link5" href="action.asp?action=5&target=' + targetname + '">View Profile</a>'
    menu1[6]='<a name="link6" href="action.asp?action=6&target=' + targetname + '">View Guns</a>'
    menu1[7]='<a name="link7" href="action.asp?action=7&target=' + targetname + '">Offer Trade</a>'
    menu1[8]='<a name="link8" href="action.asp?action=8&target=' + targetname + '">Send Cash</a>'
    }
    
    //Contents for menu 2, and so on
    //var menu2=new Array()
    //menu2[0]='<a href="http://www.javascriptkit.com/cutpastejava.shtml">Free JavaScripts</a>'
    //menu2[1]='<a href="http://www.javascriptkit.com/javaindex.shtml">JavaScript tutorials</a>'
    //menu2[2]='<a href="http://news.bbc.co.uk">JavaScript Reference</a>'
    //menu2[4]='<a href="http://www.javascriptkit.com/java/">Java Applets</a>'
    //menu2[3]='<a href="http://www.javascriptkit.com/dhtmltutors/">DHTML & CSS</a>'
    //menu2[4]='<a href="http://www.javascriptkit.com/howto/">Design Tutorials</a>'
    		
    var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
    var horizontaloffset=2 //horizontal offset of menu from default location. (0-5 is a good value)
    
    /////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: 160px" 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=-500
    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-obj.offsetWidth < 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 menu up?
    edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
    if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either? (position at top of viewable window then)
    edgeoffset=dropmenuobj.y
    }
    }
    return edgeoffset
    }
    
    function populatemenu(what){
    if (ie4||ns6)
    dropmenuobj.innerHTML=what.join("")
    }
    
    
    function dropdownmenu(obj, e, menucontents, menuwidth, targetname){
    createmenulinks(targetname)
    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")+obj.offsetWidth+horizontaloffset+"px"
    dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"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)
    }
    
    </script>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    <style type="text/css">
    <!--
    body,td,th {
    	color: #FFFFFF;
    }
    body {
    	background-color: #000000;
    }
    .style2 {color: #FF9900}
    a:link {
    	color: #FF9900;
    }
    a:visited {
    	color: #FF9900;
    }
    a:hover {
    	color: #FF9900;
    }
    a:active {
    	color: #FF9900;
    }
    -->
    </style>
    </head>
    
    <body>
    <span class="style2"><a href="#" onMouseover="dropdownmenu(this, event, menu1, '165px', 'myusername')" onMouseout="delayhidemenu()">myusername</a></span>
    </body>
    </html>

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
  •