javascript function in url (arrggg)

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
landolt
Beginner
Beginner
Posts: 3
Joined: Wed Sep 03, 2003 11:56 am

javascript function in url (arrggg)

Post by landolt »

hi

i want do a javascript function in the url-tag. but I get always the same error. i had the function in every damn js-file declare. but alway the same.

Error: todo is not defined
Zeile: 1

Code: Select all

aI("image=images/menu/rot.gif;text=testmenu;url=javascript:todo();showmenu=Anlass;target=body;");

function todo()
    {
	 do something.....
	}

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

Post by Maz »

Its a good idea to search the forum.

Either this link or search for javascript for examples.

viewtopic.php?p=8619

maz
User avatar
Hergio
Milonic God
Milonic God
Posts: 1123
Joined: Wed Jun 12, 2002 7:46 pm
Location: Rochester, NY

Post by Hergio »

Define todo BEFORE you call for it in a menu item. Put your declaration for todo and the top of your menu files or put it in another .js file but include it before the menu scripts.
Dave Hergert
Software Engineer
"Helping to make the menu better, one :?: at a time."
landolt
Beginner
Beginner
Posts: 3
Joined: Wed Sep 03, 2003 11:56 am

Post by landolt »

I defined the script at the top of my file. I tried also to put it in a another js.file an declare it bevor the other two.

I need a onclick-event. Why isn't there a function like onclickfunction like onfunction?

Code: Select all

aI("text=Testmenu;onfunction=over(0);offfunction=out(0);url=javascript:clic(0);target=body;");

And here is my declaration in the head:

Code: Select all

<HTML>
<HEAD>

<SCRIPT language="JavaScript">
function clic(no)
{
	.....
}
</SCRIPT>
<SCRIPT language=JavaScript src="css/milonic_src.js" type=text/javascript></SCRIPT>
<SCRIPT language=JavaScript src="css/menu_data.js" type=text/javascript></SCRIPT>
</HEAD>

@maz
i searched the hole forum bevor, but i didn't find my problem.
your link describes something differents.[/code]
User avatar
Maz
Milonic God
Milonic God
Posts: 1717
Joined: Fri Jun 06, 2003 11:39 pm
Location: San Francisco
Contact:

Post by Maz »

Sorry, Dave knows about java, if you are trying to open the menu from a link, there was a script written in an earlier version of menu.htm page, but I don't see it anymore. Try saying exactly what you want it to do, its difficult to understand.
Regards
maz
User avatar
Hergio
Milonic God
Milonic God
Posts: 1123
Joined: Wed Jun 12, 2002 7:46 pm
Location: Rochester, NY

Post by Hergio »

So are you saying it still doesn't work?
If so, then keep the function definition in the HEAD of your page. But move the <SCRIPT>'s for the menu to just beneath the BODY tag of the page.
Yea we have seen a possible need for an onClick event handler, rather than putting the javascript: into the url...this has caused VERY minor problems in the past (ie. stops animated Gifs on the page). Its not exactly the most pressing feature upgrade at the moment, but I think it could get implemented soon. Stay tuned.
Dave Hergert
Software Engineer
"Helping to make the menu better, one :?: at a time."
Post Reply