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: Archived Topics for the old Version 3.0 JavaScript Menu
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:31

onmouseover event on menu item? Possible?


Poster: Zophar
Dated: Friday May 16 2003 - 12:59:52 BST

Hi there ;)

Just a question:

Im trying to assign a javascript function to an "onmouseover" event for the menu item. Is there a way to do that!? For example i want my infoBulle() function to run when i put my mouse over a certain menu item (see the code). Where do i need to call my function!? I put it in the "Alternate URL" propertie but nothing happen. I also try many other but nothing happen.
Somebody has the answer!?


Code:
addmenu(menu=[      // This is the array that contains your menu properties and details
"menu2",         // Menu Name - This is needed in order for the menu to be called
118,            // Menu Top - The Top position of the menu in pixels
172,            // Menu Left - The Left position of the menu in pixels
,               // Menu Width - Menus width in pixels
1,               // Menu Border Width
,               // Screen Position - here you can use "center;left;right;middle;top;bottom" or a combination of "center:middle"
style1,            // Properties Array - this is set higher up, as above
1,               // Always Visible - allows the menu item to be visible at all time (1=on/0=off)
"left",            // Alignment - sets the menu elements text alignment, values valid here are: left, right or center
,               // Filter - Text variable for setting transitional effects on menu activation - see above for more info
,               // Follow Scrolling - Tells the menu item to follow the user down the screen (visible at all times) (1=on/0=off)
1,                // Horizontal Menu - Tells the menu to become horizontal instead of top to bottom style (1=on/0=off)
,               // Keep Alive - Keeps the menu visible until the user moves over another menu or clicks elsewhere on the page (1=on/0=off)
,               // Position of TOP sub image left:center:right
,               // Set the Overall Width of Horizontal Menu to 100% and height to the specified amount (Leave blank to disable)
,               // Right To Left - Used in Hebrew for example. (1=on/0=off)
,               // Open the Menus OnClick - leave blank for OnMouseover (1=on/0=off)
,               // ID of the div you want to hide on MouseOver (useful for hiding form elements)
,               // Background image for menu when BGColor set to transparent.
,               // Scrollable Menu
,               // Reserved for future use
," gĂ©rez votre quotidien ","quotidien.html","javascript:infoBulle('quotidien');","",1 // "Description Text", "URL", "Alternate URL", "Status", "Separator Bar"
," faites fructifier vos avoirs ","",,"",1
," financez vos projets ","",,"",1
," assurez votre avenir ","",,"",1

])


Poster: kevin3442
Dated: Friday May 16 2003 - 18:56:47 BST

Hi Zophar,

The menu's onfunction property is what you're looking for; you can use it to specify a function to run when the user mouses over the menu item. Where you use it depends on whether the menu item is a link or opens a submenu. Here's how:

If the menu item is a link (or a javascript function call):
Code:
,"Menu Text","the_url.html onfunction=yourFunctionName(params)",,,1

If the menu item opens a submenu, you have to move the alternate property definitions to the next field, like this:
Code:
,"Menu Text","show-menu=subMenu1","# onfunction=yourFunctionName(params)",,1

That should work. There's also an equivalent to onmouseout, which is the menu's offfunction property.

Hope that helps,

Kevin


Poster: Zophar
Dated: Monday May 19 2003 - 9:37:10 BST

Thx kevin for your answer... It helps me a lot and now it woks fine!!!!
I said "now" cause i found another problem ;) I have problem to assign my parameters... When i want to put a string as params nothing happens (or i get a javascript error)... example:


Code:
,"Menu Text","the_url.html onfunction=MyFunction('Hello')",,,1


-the string "hello" will cause a javascript error... btw i declared my string just before and simply put it as the param of my function and it work like that
Code:
var myString="Hello";

,"Menu Text","the_url.html onfunction=MyFunction(myString)",,,1

With this method no problem :)

Well seeing that reminded me to use the escape caracter for the quotes as follow:
Code:
,"Menu Text","the_url.html onfunction=MyFunction(\'Hello\')",,,1

but this won't works...

The funniest thing is that when i try to call a simply alert method... IT WORKS with the string quoted... like that:
Code:
,"Menu Text","the_url.html onfunction=alert('Hello Wolrd')",,,1


That's all ;) (Sorry for my bad english) If someone has other info/bug about onfunction and offfunction just put it here...

And Kevin thank you very much for you reply ;)
[/code]