Results 1 to 4 of 4

Thread: anylink menu- js link locations & images

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

    Default anylink menu- js link locations & images

    Hi there. I just got anylink drop down menu up and running for my site, and it works great!

    Here's where to find it:
    http://www.dynamicdrive.com/dynamici...pmenuindex.htm

    I want to create one more dropdown, however, with a bunch of buttons so visitors can bookmark my page on delicious, or open a popup, among other things.

    My button for delicious, for example, would have a link location like:

    Code:
    javascript:(function(){f='http://delicious.com/save?url='+encodeURIComponent(window.location.href)+'&title='+encodeURIComponent(document.title)+'&v=5&';a=function(){if(!window.open(f+'noui=1&jump=doclose','deliciousuiv5','location=yes,links=no,scrollbars=no,toolbar=no,width=550,height=550'))location.href=f+'jump=yes'};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})()
    The button would also use an image instead of text. In this example, we have:

    http://delicious.com/favicon.ico

    Pasting these values into menucontents.js doesn't work. I have a feeling this is because (1)the values in menucontents.js are not full links, and (2) these values are defined within qoutation marks (the program looks for values between the " " ).


    I took a peek at anylinkmenu.js, and here is the section that generates the html links for the menu. The program creates links by pasting the link url and corresponding link text into a sort of link template.


    Code:
    getmenuHTML:function(menuobj){
    	var menucontent=[]
    	var frag=""
    	for (var i=0; i<menuobj.items.length; i++){
    		frag+='<li><a href="' + menuobj.items[i][1] + '" target="' + menuobj.linktarget + '">' + menuobj.items[i][0] + '</a></li>\n'
    		if (menuobj.items[i][2]=="efc" || i==menuobj.items.length-1){
    			menucontent.push(frag)
    			frag=""
    		}
    	}
    	if (typeof menuobj.cols=="undefined")
    		return '<ul>\n' + menucontent.join('') + '\n</ul>'
    	else{
    		frag=""
    		for (var i=0; i<menucontent.length; i++){
    			frag+='<div class="' + menuobj.cols.divclass + '" style="' + menuobj.cols.inlinestyle + '">\n<ul>\n' + menucontent[i] + '</ul>\n</div>\n'
    		}
    		return frag
    	}
    },
    What I'm considering is to have my links saved in menucontents.js as entire links, just one list- not two columns. Next, I would change the above code to just paste the entire link from menucontents.js.

    What do you think? Suggestions? Is there anything I missed? Will you please help me implement these changes? I'm decent with computers, but not much of a javascript guy. Thanks in advance. Your help and comments are much appreciated.
    -Max

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

    Default

    moderator, please forgive me. I am new here, and just read the sticky about how i should post in the other forum.

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by maxsbonsai View Post
    moderator, please forgive me. I am new here, and just read the sticky about how i should post in the other forum.
    No prob Bob, I moved it for you. Just don't do it again, please.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Feb 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi again. I got it working with pictures on my own. Here's the hack for anylinkmenu.js:
    Code:
    getmenuHTML:function(menuobj){
    	var menucontent=[]
    	var frag=""
    	for (var i=0; i<menuobj.items.length; i++){
    		if (menuobj.items[i][3]=="img"){ 
    			frag+='<li><a href="' + menuobj.items[i][1] + '" target="' + menuobj.linktarget + '"><img src="' + menuobj.items[i][0] + '"></a></li>\n' 
    		}
    		else{
    			frag+='<li><a href="' + menuobj.items[i][1] + '" target="' + menuobj.linktarget + '">' + menuobj.items[i][0] + '</a></li>\n'
    		}
    		
    		if (menuobj.items[i][2]=="efc" || i==menuobj.items.length-1){
    			menucontent.push(frag)
    			frag=""
    		}
    	}
    	if (typeof menuobj.cols=="undefined")
    		return '<ul>\n' + menucontent.join('') + '\n</ul>'
    	else{
    		frag=""
    		for (var i=0; i<menucontent.length; i++){
    			frag+='<div class="' + menuobj.cols.divclass + '" style="' + menuobj.cols.inlinestyle + '">\n<ul>\n' + menucontent[i] + '</ul>\n</div>\n'
    		}
    		return frag
    	}
    },
    What i did here was add an if statement to check for the presence of the phrase "img" on a 4th colum (represented by menuobj.items[i][3] in above the code). If [i][3]==img, then the program prints the image url located in [i][0] into a linked image template. Otherwise, it generates the normal text link.



    Here's a sample of what a normal link looks like in menucontents.js:
    Code:
    ["Dynamic Drive", "http://www.dynamicdrive.com/"],

    Here's a sample of what a link that starts a new row looks like in menucontents.js:
    Code:
    ["Dynamic Drive", "http://www.dynamicdrive.com/", "efc"],
    Notice the third column menuobj.items[i][2]==efc to signal new row

    Now here's a sample of what a linked image looks like in menucontents.js:
    Code:
    ["http://www.dynamicdrive.com/favicon.ico", "http://www.dynamicdrive.com/","","img"],
    Notice menuobj.items[i][2] is needed to create menuobj.items[i][3]==img

    Thanks for looking. I will post a link to my site once i've got my menu finished, so you can all see what it looks like.

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
  •