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: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:18

Javascript error with Amazon style menu


Poster: aguen
Dated: Saturday January 7 2006 - 21:56:33 GMT

Hi!

I test an amazon style menu where some items of the top level menu opens a submenu (via showmenu=) while other items directly opens an url (via url=). Here is a simple code example:

_menuCloseDelay=500;
_menuOpenDelay=150;
_subOffsetTop=2;
_subOffsetLeft=-2;

forgetClickValue=true;

with(menuStyle=new mm_style()){
openonclick=1;
}

with(submenuStyle=new mm_style()){
}


with(milonic=new menuname("Main Menu")){
alwaysvisible=1;
left=0;
top=0;
orientation="horizontal";
openstyle="tab";
style=menuStyle;
aI("showmenu=submenu1;text=Main1");
aI("showmenu=submenu2;text=Main2;");
aI("showmenu=submenu3;text=Main3;");
aI("url=somelink.html;text=Main4;");
}

with(milonic=new menuname("submenu1")){
alwaysvisible=0;
left=0;
top=20;
orientation="horizontal";
keepalive=1;
style=submenuStyle;
aI("url=url1.html;text=Sub1;");
aI("url=url2.html;text=Sub2;");
aI("url=url3.html;text=Sub3;");
}

with(milonic=new menuname("submenu2")){
alwaysvisible=0;
left=0;
top=20;
orientation="horizontal";
keepalive=1;
style=submenuStyle;
aI("url=url4.html;text=Sub4;");
aI("url=url5.html;text=Sub5;");
}

with(milonic=new menuname("submenu3")){
alwaysvisible=0;
left=0;
top=20;
orientation="horizontal";
keepalive=1;
style=submenuStyle;
aI("url=url6.html;text=Sub6;");
aI("url=url7.html;text=Sub7;");
}

drawMenus();


With this configuration I got the following problem:
When I click (for example) "Main2" (opens Submenu1) and after that Main4 (should open somelink.html) I get an javascript error: 'somelink' is undefined. Only when I click Main4 for a second time it opens the page somelink.html.
The general problem is: Opening a submenu before clicking a item that opens a page direclty causes this error. When I click the direct link first everything is ok.

Some idea/help on this?

Thanks a lot!
Armin


Poster: vikenk
Dated: Sunday January 8 2006 - 13:45:02 GMT

Armin,
Where do you get this "'somelink' is undefined" error, in which browser? That sounds like a FrontPage error. Secondly, is that your actual code that you listed? If so, you fogot a semi-colon after Main 1 (before the end-quote), which may pose a problem.

aI("showmenu=submenu1;text=Main1");

Third, Can you post a sample URL or soma actual code (if what you listed is not your actual code)?

Viken K.


Poster: aguen
Dated: Sunday January 8 2006 - 15:50:07 GMT

Viken,
thank you for your reply!

1.
I get the javascript error in IE 6.0.x:
"error on page" (in German: Fehler auf der Seite) at the left corner of the status bar. When I open the details box I get the explanation "'somelink' is undefined" (actually: "'somelink' ist nicht definiert").

No, FrontPage is not involved.

I tested the code with Mozilla 1.7.5 too with essentially the same result. There is no error message but the direct link works only when the link is clicked twice, i.e. the script misbehaves with the first click.

2.
No, it is not the actual code. I test the Milonic menu for a client of mine and the actual page is not yet publicly available.
I added the missing semi-colon (thank you!) but this did not change anything.

3.
I have made up a test page here:

http://www.psycline.de/testfolder/test.html

Click "Main2",
then click "Main4".
Now you should get the error (at least no page is opend).
Click "Main4" again and now "somelink.html" is opend.

Thank you!
Armin


Poster: vikenk
Dated: Monday January 9 2006 - 17:50:08 GMT

Try taking out openonclick=1; from your Main Style. It did the trick in my tests. Things were much more predictable.

Let us know how it works.

Viken K.


Poster: aguen
Dated: Tuesday January 10 2006 - 7:31:52 GMT

Viken,
thanks again for your reply and your advice!

You are right: without openonclick=1; there is no javascript error. But unfortunately my client would like to have openonclick=1.

To say the truth: I think there is a bug in the script that should be fixed anyway. There should be no javascript error with a valid configuration file.

But even if you drop "openonclick=1;" there remains a strange behavior:
If you click on the main menu (okay it makes no sense if you have openonclick=0 for this menu - but if you nevertheless happen to click on it) you have to click the direct link twice before it opens a url. Here is an example:

http://www.psycline.de/testfolder/test2.html

Click "Main3" and then click "Main4": "Main4" will not work. Only after clicking Main4 again it does.

That means: If you drop "openonclick=1;" you get rid of the javascript error but the overt behavior is the same as before: the direct link ("Main4") does not work with the first click.

Armin


Poster: vikenk
Dated: Tuesday January 10 2006 - 13:35:28 GMT

Hmmm... I didn't notice that. When I tested it, I was sure that removing the openonclick=1 command got rid of the "click-twice" behavior. But now that I go back and re-test it, it's still happening.

I am at a loss for words.

Viken K.


Poster: aguen
Dated: Friday January 13 2006 - 23:33:56 GMT

I am still in search for a solution of this error. Could someone of the team have a look at it?

Thanks!
Armin