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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reuse main navigations 1

Status
Not open for further replies.

A1Pat

IS-IT--Management
Jun 7, 2004
454
US
Hi all,

I'm trying to find a shorter way to include my main navigation links to every HTML pages of mine.

Instead of copy and paste all of them to every new page, I'm looking for a way to just create the main navigations once, then call it whenever a new page is created.

For example, in ASP, <!--#include file="xxx.html"--> is used to add the particular page to the new page.

Thanks!
 
Without a scripting language (JSP, ASP, PHP), this is only possibly by utilizing server-side includes. Does your server support ssl?

*cLFlaVA
----------------------------
Breaking the habit...
 
There are several ways to do that:

- server-side includes (SSI)
- frames
- javascript include (may look sluggish for larger menus/navigations)
- "shared border" feature in editors a la FrontPage, which is basically hi-tech version of copy&paste
- manual copy & paste :)
 
Sadly, no.

I'm utilizing free webhosting that doesnot support anything but HTML, HTM.

Seemed like I have no choice but to copy and paste the navigation on every page then.

Thanks :)
 
Your other option, as Dave said, is using a .js file to write your links on every page.

This will result in slightly slower load times, but if you don't have a ton of images, it might work ok for you.

*cLFlaVA
----------------------------
Breaking the habit...
 
Sorry, not Dave, vongrunt.

*cLFlaVA
----------------------------
Breaking the habit...
 
:)

it just happens that I'm doing this next page displaying my images, many and many of my images. If .js has problem w/ images while loading then I'm afraid that is not an option either.

:)
 
By the way, does anyone know where can I acquire a free webhosting where ASP is allowed?

Thank you for the help
 
A1Pat-

I put together an example for you.

Here's index.html:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script language="JavaScript" src="the_js.js"></script>
</HEAD>

<BODY>
<table border="1"><tr valign="top">

<!-- start menu section -->
<td><script language="JavaScript">writeNavigation();</script></td>
<!-- end menu section -->

<!-- start content section -->
<td>This is where the content goes.</td>
<!-- end content section -->
</tr></table>
</BODY>
</HTML>

And here's the_js.js - Place them in the same directory for this to work:
Code:
function writeNavigation() {
	// initialize the string to write to the document
	var str_to_write = '';

	// begin building the string
	str_to_write += '<table border="0"><tr valign="top">';
	str_to_write += '<td><a href="[URL unfurl="true"]http://www.google.com/">Google</a></td>';[/URL]
	str_to_write += '</tr><tr valign="top">';
	str_to_write += '<td><a href="[URL unfurl="true"]http://www.yahoo.com/">Yahoo!</a></td>';[/URL]
	str_to_write += '</tr><tr valign="top">';
	str_to_write += '<td><a href="[URL unfurl="true"]http://www.tek-tips.com/">Tek-Tips</a></td>';[/URL]
	str_to_write += '</tr></table>';

	document.writeln(str_to_write);
}



p.s. - I doubt you'll find any free hosting plans that provide any scripting language support.

*cLFlaVA
----------------------------
Breaking the habit...
 
I've created secondary navigation within a website using an SSI file. It's a list of links. I would like to add some logic so that when you're on one of the pages in the link list, that particular link becomes inactive or perhaps just without text-decoration. I'm not sure how to go about that. Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top