design question

H

headware

Hi, I have a general design questions. I'm making a site that has two
frames, one on the left for navigational menus and one on the right
for displaying the contents of the site. I want some of the menu items
on the left to expand dynamically and display sub items when the user
clicks on them. So they might show something like this:


item 1
item 2
item 3

then when you click on item 2 you get this:

item 1
item 2
sub item 2.1
sub item 2.2
item 3

I was going to put all the javascript in just the menu pages so that
when you click on one of the expandable menu items, it loads another
static page into the left frame with that menu item expanded. I know
that may not be the best solution especially if we decide to have more
than one expandable menu item, but that's the way it's going to work
for now.
This would have worked fine except that some pages allow the user
to access other pages without using menu on the left. The problem
there is that if a page that isn't part of an expanded menu item takes
you to another page that *is* part of an expanded menu item, the menu
won't expand, since the javascript only runs if you click the menu
item hyperlinks in the left pane.
This problem can be solved in at least a few ways. I could take the
javascript out of the menu pages and put it in the onLoad event of
every display page so that when that page displays, it changes the
left frame to display the proper menu for that page (expanded or
collapsed). Or I could connect the javascript to the hyperlinks that
move you from pages with collapsed menus to pages with expanded menus.
Neither of those solutions sounds all that good because every time you
right a new page you have to remember to put the javascript in there
if it's going to affect the menu frame. Is there any other way of
doing this that I might be missing? Something that won't turn into a
maintenance nightmare?

Thanks
 
H

headware

Unfortunately I don't have a choice.

William Starr Moake said:
The instant I read the word "frames" my eyes glaze over, my brain
turns to oatmeal and drool runs down my slack jaw. Don't use 'em.
Don't want to read about anyone else who does.
 
D

Dom Leonard

headware said:
Hi, I have a general design questions. I'm making a site that has two
frames, one on the left for navigational menus and one on the right
for displaying the contents of the site.
This would have worked fine except that some pages allow the user
to access other pages without using menu on the left. The problem
there is that if a page that isn't part of an expanded menu item takes
you to another page that *is* part of an expanded menu item, the menu
won't expand, since the javascript only runs if you click the menu
item hyperlinks in the left pane.
This problem can be solved in at least a few ways. I could take the
javascript out of the menu pages and put it in the onLoad event of
every display page so that when that page displays, it changes the
left frame to display the proper menu for that page (expanded or
collapsed).
This has potential in that pages could include common code to cause menu
update based on their URL. I would not, however, attempt to get document
page code to *perform* menu update. More some kind of notification to
let frameset or contents page code know that the document frame URL has
changed.

Or I could connect the javascript to the hyperlinks that
move you from pages with collapsed menus to pages with expanded menus.
Bad idea, no disagreement. Horrible maintenance problem.
Neither of those solutions sounds all that good because every time you
right a new page you have to remember to put the javascript in there
if it's going to affect the menu frame. Is there any other way of
doing this that I might be missing?
I have used the 'notification' solution with no action taken if the
notified URL is not in the menu. Essentially common menu interface code
goes in a template file for frameset documents.

Another idea might be to run a timer script in either the frameset or
contents page which checks for *changes* in the url of the document
frame, and if an inactive menu link points to it, update the menu frame.
This suggests even static menu pages loaded from the server need to know
where hidden menu links lead.

There might be a small delay before menus update themselves (which is
exactly what I think menus should do) but this might actually be better
than page loading scripts using a notification scheme - clicking a menu
item to load a document frame can cause duplicate tracking if menu item
click and page loading both trigger contents tracking without additional
code to prevent the duplication.

Obviously a fully expanded contents page should be loaded initially by
the frameset for use in javascript disabled browsers.


Hope it helps,
Dom
 
H

headware

Thanks for the reply. Those are good suggestions. But, why do you
think it's a bad idea for the document page to do the actual changing
of the menu page? All it would really require is some simple code like

parent.menu.location = "MyMenu.aspx";

Do you think this could lead to maintenance issues?

Thanks,
Dave
 
D

Dom Leonard

headware said:
Thanks for the reply. Those are good suggestions. But, why do you
think it's a bad idea for the document page to do the actual changing
of the menu page? All it would really require is some simple code like

parent.menu.location = "MyMenu.aspx";

Do you think this could lead to maintenance issues?

In the sense that the document page has hard links to its associated
menu page, yes. I think it preferable for javascript code to derive the
menu page from parsing the document URL in which the code is running.

So if the document url looks like "http://...blah.../page1.html
and code parses out the 'page1' bit into a pageName variable, the above
code might become

parent.menu.location = pageName + "Menu.aspx"; // or
parent.menu.location = "sendMenu.asp?caller=pageName";

A common javascript file can then be included in document pages to
update the menu. Hard coding may be fine for a few pages, but does not
scale well and requires the navigation system to stay constant.

I have found a common .js file is a good idea anyway. I wanted to add a
frame breakout script? Reload under Netscape 4.xx after resize? Create
and add a document footer element? Easy with a common file :)

Cheers,
Dom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,077
Messages
2,570,566
Members
47,202
Latest member
misc.

Latest Threads

Top