Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML - Basic Basic Question

Status
Not open for further replies.

sanders720

Programmer
Aug 2, 2001
421
US
At least I'd have to think this is a basic question!

I have a menu section on a web page, and a main section. There will be several pages. I do not want to repeat the menu on every page. Is there a way to do the menu once, and somehow include it on each web page?

Thanks for any help you can provide.
 
Are you using a scripting language, such as PHP or ASP?

The only way I know of to include a file is by doing so with a server-side include.

In PHP, it looks like this:

Code:
<?
include("path/to/include.html");
?>

*cLFlaVA
----------------------------
Ham and Eggs walks into a bar and asks, "Can I have a beer please?"
The bartender replies, "I'm sorry, we don't serve breakfast.
 
No, just HTML. I'm too much of a novice to get into scripting right now.

I am wondering if I can do an include from HTML?
 
depending on your server you may be able to use SSI

SSI Developer shameless plug for cian's website (TT member)



Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
I am wondering if I can do an include from HTML?
No you can't...
Unless you use Frames wich is just a really uncool thing to do nowadays.

What you could have is a call to a Javascript function that generates the menu for you.

Lets say you have three pages PageUno.htm, PageDos.htm and PageTres.htm on the HEAD of everyone call a Javascript file and right after the <body> tag have something like
Code:
<script>
create_menu;
</script>


This way if you need to change something on your menu you just change it on the Javascript file and it will get generated on all three pages without having to do it for each one.


PRO:Once the Javascript is loaded it will get cached, making the whole thing faster on subsequent pages.

CON: if Javascript is disabled the whole menu will be gone.
CON: If you want your pages to be accesible, the code generated by the function may not be picked up by some readers.

If you don't want to go through all the problem of creating your own ouptu lines like :
Code:
document.write('<table><tr><td>insert your own content</td></tr></table>');

check the internet for scripts that get the HTML as an input and output the Javascript lines for you.

good luck

grtfercho çB^]\..
"Imagination is more important than Knowledge" A. Einstein
-----------------------------------------------
 
If I were to attempt Javascript, what would I need to know? I think I could pull it off.

I'm assuming create_menu is the script. How would this look aside from the lines of HTML code (I assume these are verbatum)?
 
I strongly suggest not using JavaScript for what you are trying to do.

According to w3schools, 10% of people have JavaScript disabled. That's 1 out of 10. Would you like 1 out of every 10 people that see your site to not even see the menu?

I suggest either:
1) make absolutely sure your menu looks the way you want it to on ONE page, then copy and paste. Keep the one page around for the next time you want to alter the content. Copy and paste again, or, run a script using VBA, VB, anything, to replace the code in the files.

2) Get your client (or yourself) on a scripting language.

Hope this helps.

*cLFlaVA
----------------------------
Ham and Eggs walks into a bar and asks, "Can I have a beer please?"
The bartender replies, "I'm sorry, we don't serve breakfast.
 
Just out of curiosity, I used include like this...

<!--#include file = "xxx.html"-->

It shows up great in the Dreamweaver preview, but not on the page. Is this what you are referring to about scripting languages, or is there another issue I need to understand?
 
SSI will only work when the page is delivered from a server. DW preview can simulate the SSI operation.

using javascript to script on your navigation will also render the navigation invisible to search engines as well.



Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
SSI is the way to go. It is much better than copy and paste. This way if you make a change to the menu you only have to do it in one place.

You just have to make sure that SSI is enable on your web server and that your pages that contain the includes are renamed to .shtml.
 
>>It shows up great in the Dreamweaver preview

If you are using Dreamweaver, then you can use the Library feature.
 
jem122974: Can you elaborate on SSI? I am creating an intertan intranet document which may never even be placed on a server - strictly for local use. Will this work, and how can I get started on understanding it?

Thanks for the help!
 
how would you do this using SSI?????

thanks in advance

Jonathan D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top