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:21

Swapimage - could one do something to 'swaptext'?


Poster: Ruth
Dated: Friday August 8 2003 - 9:27:12 BST

I have used the swap image and it works fine, but I was wondering if it were possible to 'swaptext' using onMouseover? I'm sure I saw something somewhere about changing text on mouseover but I don't know if it could be done in the menu? It would be real nice as an option, save having to use images for swaps, save having to make different ones for different things if a text swap were possible. But, I have no idea if something like that is or if it's feasible. Thanks in advance. :D

Ruth


Poster: Hergio
Dated: Friday August 8 2003 - 16:36:11 BST

You're darn right its possible, isn't most anything! ;)
I looked and didnt see a menu function that would handle it, but try this out, it worked for me!

in the head of your page, put this in:
Code:
<SCRIPT>
function changeText(id,toThis)
{id.innerHTML = toThis;}
</SCRIPT>


And then to make text change based on mouse over in the menu items, create your menu text field like so...pay attention to quotes and single quotes cuz we're trying to trick the menu. Also DO NOT put any semi colons after the javascript calls...andys script parses up your strings using semicolons and it totally screwed me for the longest time.

Code:
aI("text=<span onMouseOut=\"changeText(this,'New Out Text')\" onMouseOver=\"changeText(this,'New In Text')\">Original Text</span>;url=http://www.example.com;");


Worked for me on a Win2000 machine using Internet Explorer 6. If you want it to work on other browsers, you may have to do alittle tweaking, but not too much I dont think. You're essentially putting alittle span tag in place of the next and telling it to change its innerText based on mouseOver and mouseOut, the menu has nothing to do with it.

Hope it works for you!!


Poster: Hergio
Dated: Friday August 8 2003 - 16:46:15 BST

Ok i am stupid sometimes. I was dumb about two things.
(1)I totally forgot we are using the v3 of the menu here,
(2)If the menu is wider than the text, the onMouseOver only works on the text, not the entire menu so basically you could hover over part of the menu item, but the text wont change until you go over the text.
Heres the fixes
Below is how you would define a menu item in the menu:
Code:
,"<table width=100% ><tr><td onMouseOut=\"changeText(this,'New Out Text')\" onMouseOver=\"changeText(this,'New In Text')\">Original Text</td></tr></table>","http://www.example.com onbordercolor=0000ff;offbordercolor=FFFFFF;",,"ExampleHome",0


What I did differently here is first, changed it to version 3, so it should still render. The second thing is instead of a span tag, I used a table tag. This way I set the table to 100 % width and it consumes the entire menu item cell, so the mouseover will work everywhere within the item cell.

Sorry about the stupidity. Hope this works, let me know if you have problems!


Poster: Ruth
Dated: Friday August 8 2003 - 21:48:14 BST

Ok, what the heck am I doing wrong? I put the code in but whenever I mouseover I get an error message that an object is expected.

I do have another option, I used it in the one down from this one..9-11, that's text and it imitates a 'mouseover' but uses image swap, I just put in a transparent 1x1 px image after the words and another image for the swap, but I'd like to get away from images. Text swap would mean not having to make new images to go with colors if I change those. Thanks so much for the help. [at some point I will be going up to 5, but not until I get the menu up and functioning as I want...it takes too long for me to figure out how to do things inside the menu]


Ruth :)


Poster: Hergio
Dated: Monday August 11 2003 - 3:53:13 BST

If you look at the post of mine before last, you will see where I defined a function called changeText....this is the 'object' that it can't find. When you have your mouse over events do function calls, they call a function object and if it can't find the reference or definition of it, it errors out. Take the code in that post, including the < SCRIPT > tags and paste it into your head of your document...it should work then. Everything else seems fine.