Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:58

putting a script function in the url= parameter


Poster: Derek NYC
Dated: Wednesday January 5 2005 - 5:45:15 GMT

Hi,
I'm not sure of the best way to go about this. I'm using the menu for a catalog that contains lots of long query strings as links, with the only difference in the string being one parameter (like subcat=10, subcat=5, etc.)

I could cut down the file size a lot if there was a way I could set a default for most of the string and then just tack on the different ending for each menu listing.

Any ideas how I could best incorporate this into the Milonic framework?

Thanks,
Derek


Poster: Ruth
Dated: Saturday January 8 2005 - 6:30:23 GMT

I know you can use a function in the url parameter, however, I am not a function person. I don't know how to create one. If you know how to make functions, then maybe the following example can give you some direction.

The function relates to opening a new window in a particular position and it is called in the url parameter:
Code:
var newwindow;
function poptastic(url)
{
   newwindow=window.open(url,'name','height=500,width=400,left=100,
  top=100,resizable=yes,scrollbars=yes,toolbar=yes,status=yes');

}

Then in the aI string you'd have this to get it to trigger:
Code:
aI("text=item;url=javascript:newwindow('http://whatever/');");
I'm sorry I can't more directly answer your question :(

Ruth


Poster: Derek NYC
Dated: Saturday January 8 2005 - 21:19:42 GMT

It at least gets me on the right track. I can put together something that should work. You reply is most appreciated, Ruth. Thank you.

Derek


Poster: kevin3442
Dated: Tuesday January 11 2005 - 0:47:25 GMT

Hi Derek,

Since menu_data.js is all javascript and the parameter passed to Milonic's aI() function is a string (often referred to here as the "aI string"), you could use js string concatenation when building the string to pass to aI(). For example, suppose your base url was:

http://www.mysite.com/products/catalog.html?subcat=

You could define the base url in a global string variable at the top of your menu_data.js file, like so:
Code:
var baseUrl = "http://www.mysite.com/products/catalog.html?subcat=";

Then when you want to build an aI string for a menu item, you'd define the static properties at the beginning of the string (like text=... status=... etc.), then concatenate the baseUrl variable to the aI string, then concatenate the value of the parameter you want to pass at the end of the aI string, like so:
Code:
aI("text=Item Text;url=" + baseUrl + "10;");

(You could skip the space on either side of the + operator if you want to save even more space... no pun intended). The resulting url for the menu item defined above would be:

http://www.mysite.com/products/catalog.html?subcat=10

Of course, you'd want to modify the approach to suit your own particular URLs.

Hope that helps,

Kevin


Poster: Derek NYC
Dated: Tuesday January 11 2005 - 3:33:37 GMT

Thanks Kevin,

That helps a lot. I guess you are here to save the day. I have another license to buy from Milonic thanks to your help!

Derek