Javascript Function as menu item URL?

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
jondoe_264
Advanced
Advanced
Posts: 11
Joined: Thu Mar 18, 2004 11:41 am

Javascript Function as menu item URL?

Post by jondoe_264 »

Here's what I'm trying to acheive:

A sub-menu item when clicked opens a new browser window via a javascript function that is referenced to from the html page that the main menu is part of.

Where in the sub-menu items code do I need to put the javasript? What would the syntax look like? Is this even possible? I was thinking may be in the URL attribute?

aI("text=3200;url=javascript:launchSharewire(PRODUCT_ID);status=3200;");

What you think anybody?
User avatar
Maz
Milonic God
Milonic God
Posts: 1717
Joined: Fri Jun 06, 2003 11:39 pm
Location: San Francisco
Contact:

Post by Maz »

You might find an example of what you are looking for by searching the forum. I'm sure this topic has come up before.

maz
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Jondoe,

The syntax in your example is exactly correct. Another method, if you want to use a different url in conjunction with an onclick handler, is to use the clickfunction property, like so:

Code: Select all

aI("text=Item text;url=theURL.html;clickfunction=launchSharewire(PRODUCT_ID);status=3200;");
You can also use the clickfunction property in the absence of the url property.

Code: Select all

aI("text=Item text;clickfunction=launchSharewire(PRODUCT_ID);status=3200;");
You may also want to refer to this sample to learn about onmouseover (onfunction) and onmouseout (offfunction) capabilities.

Hope that helps,

Kevin
Post Reply