Solved: HTML menu

Code junkies hangout here

Moderators: ChrisThornett, LXF moderators

Solved: HTML menu

Postby tedius » Mon Oct 24, 2005 10:57 am

On my web site I have a persistent menu on every page. I use to hard code it into every page, but that got rather annoying very quickly, as any change means I have to change all my pages.

I then tried to add them menu to each page by embedding via the object tag i.e.
Code: Select all
<object type="text/html" data="menu.html">
Menu failed to load.
</object>


This loads the menu find. I now have the same menu on every page and if anything changes I only have to update menu.html. But (and there is always a but) when I clink on one of the links it opens in the sub window and not the main window.

I have a test page to show what I mean, you can find it here.

Can anyone help me with this.

Edit:
PHP and server side include is the way to go! :D
Last edited by tedius on Mon Oct 24, 2005 3:16 pm, edited 1 time in total.
User avatar
tedius
 
Posts: 84
Joined: Fri Apr 08, 2005 3:20 pm
Location: Cambridge, England

RE: HTML menu

Postby Lejon » Mon Oct 24, 2005 12:28 pm

To get the page to open in that very window, just use the TAGET="_TOP"
option in the <A> Tag.. like <a href="http://www.linuxformat.co.uk" TARGET="_TOP">link</a>
But I suspect that you want the menue to presist.
Then I surgest PHP.
And if you dont have acces to that on the server I surgest you use Frames, or iFrames.
example: if you create an iframe: <iframe name="main" src="default.html" width=100% height=80% frameborder=0></iframe>
(80% hight so that your menu still appers on top.)
and then you suply TARGET="main", in the A tag.

However with this solution, you might as well just have the menu directly in the index page.
As that will be the "mother" to the site anyway.
(object would be overkill)
I am the one you thought I was! Just not the way, you expected...
User avatar
Lejon
LXF regular
 
Posts: 150
Joined: Wed Oct 19, 2005 7:24 pm
Location: Sweden

Postby tedius » Mon Oct 24, 2005 1:42 pm

Thanks Lejon, that was what I was looking for.

Saying that the menu was persistent was probably not the correct word to use. what I meant is that I have a file (menu.html) which is just a list of links and then I embed this file into each of pay pages using the object tag.

The PHP method does seem more elegant, do you know of a good website that can show me how to do things like this? I've never used PHP though I'm pretty good a picking new languages up.

Thanks
User avatar
tedius
 
Posts: 84
Joined: Fri Apr 08, 2005 3:20 pm
Location: Cambridge, England

Postby Lejon » Mon Oct 24, 2005 2:04 pm

I am the one you thought I was! Just not the way, you expected...
User avatar
Lejon
LXF regular
 
Posts: 150
Joined: Wed Oct 19, 2005 7:24 pm
Location: Sweden

Postby tedius » Mon Oct 24, 2005 3:19 pm

Lejon wrote:http://www.w3schools.com/php/


Thanks Lejon,

That is a much better way of doing it. PHP with server side include was the thing I was really after.

Now to try out some more fancy things, with dynamic menus :D
User avatar
tedius
 
Posts: 84
Joined: Fri Apr 08, 2005 3:20 pm
Location: Cambridge, England

Postby Lejon » Mon Oct 24, 2005 6:17 pm

tedius wrote:
Thanks Lejon,

That is a much better way of doing it. PHP with server side include was the thing I was really after.

Now to try out some more fancy things, with dynamic menus :D


I wish you the best of luck :)
I am the one you thought I was! Just not the way, you expected...
User avatar
Lejon
LXF regular
 
Posts: 150
Joined: Wed Oct 19, 2005 7:24 pm
Location: Sweden

Postby ollie » Tue Oct 25, 2005 8:03 am

I agree with Lejon that PHP is one of the better ways to dynamically generate menus - but frames are one of the abonimations that should be taken out of the W3C standard. Stick to standards compliant pages that load quickly and use CSS for style so your pages are accessible to everyone - especially with the growing use of non-computers to access the Internet.
User avatar
ollie
Moderator
 
Posts: 2749
Joined: Mon Jul 25, 2005 11:26 am
Location: Bathurst NSW Australia

Re: RE: HTML menu

Postby tenba » Sun Feb 26, 2006 3:12 am

Lejon wrote:To get the page to open in that very window, just use the TAGET="_TOP"
option in the <A> Tag.. like <a href="http://www.linuxformat.co.uk" TARGET="_TOP">link</a>
<a target="_top" ...> appears to work in Internet Explorer only if you include the embedded html file using an iframe. If you are using an object Firefox will do what you want (ie open the link using the entire window). I have not figured out how to get Explorer to do it yet (assuming it's even possible).
tenba
 
Posts: 1
Joined: Sun Feb 26, 2006 2:55 am


Return to Programming

Who is online

Users browsing this forum: No registered users and 2 guests