putting a script function in the url= parameter

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
Derek NYC
Beginner
Beginner
Posts: 3
Joined: Wed Jan 05, 2005 4:03 am
Location: Lake Worth, FL

putting a script function in the url= parameter

Post by Derek NYC »

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
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

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: Select all

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: Select all

aI("text=item;url=javascript:newwindow('http://whatever/');");
I'm sorry I can't more directly answer your question :(

Ruth
Derek NYC
Beginner
Beginner
Posts: 3
Joined: Wed Jan 05, 2005 4:03 am
Location: Lake Worth, FL

Post by Derek NYC »

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
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

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: Select all

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: Select all

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
Derek NYC
Beginner
Beginner
Posts: 3
Joined: Wed Jan 05, 2005 4:03 am
Location: Lake Worth, FL

Post by Derek NYC »

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
Post Reply