I am looking for a navigation menu (and I guess that javascript is the code that I need) that changes the link in the navigation menu if the page loaded is that link. Mmmmmm.... Hard to desribe really, so don't worry if you do not understand so far...

From this page, you can see the navigation menu on the left. If you click on one of the menus, it changes to the relevant page, and then that link on the menu changes to have a different background colour than the rest.

E.g. the page above has "Britain" highlighted in another colour. If you click on "Timelines", the page changes, "Britain" becomes the "normal" background colour and "Timelines" now has the different background colour...

OK, long winded I know but I hope you understand what I am looking for. I guess the script must check the URL of the page and if it matches a link on teh page changes its style properties (so I guess also CSS is used).

If anyone can help I would be very grateful as at teh moment I have a site where I have a different navigation menu depending on teh page loaded - this is a real hassle as every time something is added to the navigation menu on one page I need to update all nav menus... And there are hundreds.

Look forward to hearing some ideas (seeing some links perhaps to source code?!).

Kor

07-04-2003, 11:32 AM

If there are independent pages (the BBC example), that is a simple CSS change of the TD background ,according to the page.
They are different pages aftera all, so they can be build each with different menu appeareace, right? :-)

If there is framed page, with the meniu fixed on the parent page, that you have to use a javascript solution.

I'll just explain my way to do so, but, first, on theory. If you think it suits to your site, or if you can do it by yourself, let me know, and I can detail to you

The general ideea is that i put in the pages BODY tags of the childframes a call on onload

Than I build a script, in parent page (the page with the menu) which can change the atributes of the (in your case) cell's background.

The script is based on getElementById method. I give ID's to the cells on the tables. I build a setup function to define each object (with the new{/B] method. I return the object style atributes with a [B]this.obj asignment, than i build that function afunction(bla) who change the styles according to the parameters returned ('link1', link2', a.s.o)

May sounds confusing, but if you don't follow me till here, I'll give you later an example.

ivy

07-04-2003, 12:31 PM

Hi Kor

Thank you for replying.

I am getting the "general" idea... An example would be excellent if you have the time.

Look forward to hearing from you.

Kor

07-06-2003, 12:23 PM

a simple structure with a menu on parent page (index.html) and two "children" pages, link1.html and link2.html, wchil will be called in a iframe)

Put them in the same root than click on the links... the cells' background will change on different inner frames onload...

ivy

07-06-2003, 04:39 PM

Hi Kor

Thank you for the example..... It works perfectly...

My only reservation is that not all browsers support iFrames.

As far as I am aware Netscape 6x supports them and so too IE5.5 and higher.

Is it a good idea to use iFrames (and that question goes to everyone - the more comments the better please).

I think that I will implement that script and test it for a while, depends on feedback with regards to the various browsers and their support for iFrames.

Once again, thank you Kor.

Kor

07-07-2003, 09:00 AM

<iframe> works for IE 5 and above, NS6 and above, all the recent Opera or AOL versions, that means over 98-99 % of the users. Fewer and fewer use NS4 or IE4, so I think it is the moment to use <iframe> in regular sites...

On the other hand, my example can be use for classical frames... I used iframes because it looks easier for me to give you a quick example...

The javascript itself works only for the same browsers as <iframe>, but here you can use a browser detect script and than, with some "if statesments" you can make it work for NS4 and IE4 as well