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

How to define menus and draw them after page has been loaded

Poster: Steven_Rosburg
Dated: Monday August 23 2004 - 18:56:31 BST


I'm completely stumped as to how to how to dynamically add menu items to a page and draw the menu once the page has already been rendered. Normally, I build the JavaScript necessary as part of a JSP page which generates all the HTML for the page, and then call drawMenus() last, which works fine.

However, I am currently trying to add menus to a page which is updated via DHTML after the page is initially rendered, and I cannot get it to work. Unfortunately, I can not submit a URL to demonstrate, but I'll try to describe the situation and see if anyone has a suggestion.

The top page, index.jsp, defines a set of frames, one of which loads ui.jsp as its source. ui.jsp declares an onLoad() event handler for <BODY>, then an <IMG> which is used as a skin, and finally a bunch of <DIV> which are used to position different pieces of information within the skin. The onLoad() event handler calls some JavaScript, which ultimately results in the execution of another JSP (Search.jsp), after ui.jsp has fiinished rendering.

Search.jsp has most of the "guts" it -- it has all the data and the logic. It dynamically updates what is being displayed by the ui page via DHTML (e.g. top.uiFrame.document.getElementById("browseArea").innerHTML = ...)

It is within Search.jsp that I need to be able to contruct the menu, since it is at this point that I have access to the database and have the info necessary to create the menu items. However, the problem that I am running into is that Search.jsp is not being rendered; it is merely updating elements on ui.jsp via DHTML, and ui.jsp has already been rendered by the time Search.jsp is processed. If I include the Milonic source in ui.jsp and try to make calls to aI() and drawMenus() from Search-Multi.jsp, they don't resolve correctly.

However, if I declare and draw the Milonic menu within ui.jsp, I can activate the menu from Search.jsp like so:

top.uiFrame.document.getElementById("browseArea").innerHTML = "<IMG style=\"position:absolute; top:15; left:5;\" onmouseover=\"popup('Main Menu')\" onmouseout=\"popdown()\" border=0 src=\"images/Skyteam/Browse.gif\"></IMG>";

The primary obstacle is that I cannot seem to be able to add menu items via aI() or call the drawMenus() function, except within the ui.jsp page. Any ideas?

Basically, is there any way to dynamically construct and display a menu via DHTML (or any other means) after after the page being displayed has initially been rendered?

Thanks and regards,

Poster: kevin3442
Dated: Saturday August 28 2004 - 0:10:28 BST

Hi Steve,

Cincidentally, someone else posted a similar question very shortly after yours. You'll find the discussion in this thread.