Jump to content

Html Files


PMA-MEGA@GEEK

Recommended Posts

Hi all,I am new to the forum and would like to thank everyone in advance for their assistance.I am creating a web page were there are two main sections. The left Div is the navigational pane which is the same for all 20 pages of the website. The right pane is all of the body. I have created the website using javascript and HTML. Basically my problem is that every time that i need to make a change to the navigational pane even if it is to correct a typo i have to do the same for all 20 pages. I have been unable to find a way to have the left navigational pane in a separate file that I can then link. Does any one know how to link 2 HTML files together for a single website?I have tried to link it the way that you would link a script file such as java but this did not work. Thanks for the assistance!PMA-MEGA@GEEK

Link to comment
Share on other sites

The easiest way is to use PHP's server side includes.If you have PHP enabled on your webhost, then all you do is copy the navigation stuff into a document, called perhaps nav.html. This file should essentially contain the elements that usually make up your navigation div/list. In place of all that stuff, you write the include:<?php include_once("nav.html"); ?>You need to save every page you want the include in as a .php file. Now, one change will be reflected in every page.

Link to comment
Share on other sites

I hate to suggest this icon8.gif but there is a JavaScript technique you can use. In the exact spot where you want your menu to appear, place a script element. It should link to a script that looks something like this:

document.write("<div>");document.write("	<ul>");document.write("		<li>item 1</li>");document.write("		<li>item 2</li>");document.write("		<li>item 3</li>");document.write("	</ul>");document.write("</div>");

That's the whole script. It writes your menu. Update it once, and the update appears in every document where you have a tag for that script. Crude but effective.

Link to comment
Share on other sites

Hahaha, that's gold.I've never thought of using javascript like that. Kinda forgot that you can link to external files.
Hi, Thanks for the assistance but i have an extremely complex drop down sliding menu that is composed of java script and HTML. I could not replace it with this simple version. Is there no way to link 2 HTML files?
Link to comment
Share on other sites

Hi, Thanks for the assistance but i have an extremely complex drop down sliding menu that is composed of java script and HTML. I could not replace it with this simple version. Is there no way to link 2 HTML files?
No, there is not. We've told you all the possible methods already.I don't see how the Javascript method wouldn't work for you, no matter how complex the other file is. You'll just have to escape a few quotation marks.
Link to comment
Share on other sites

I assume you have some CSS associated with this thing. Put it all in a special file and link to it as normal. Yes, I guess that means adding another line of code to each file where you want the menu. And you'll need to link to the JavaScript, which also can be in an external file, if it isn't already.To adapt your HTML, you'll need to strip off all the header information and the body tags (assuming you have some). Leave just the elements that need to appear.Copy what's left and paste it into a text editor. Then do some basic search/replace to add the quotes, parens, and document.write statements. And you'll need to escape the existing quotes (single and double). Setting up the search/replace will take a few minutes of trial and error, but it's not mind-boggling.Then copy/paste the edited text back into your document.----------------------If you expect to do this again sometime, you really might consider migrating your server to one that has PHP. Server side includes make life so much easier. The only PHP you'd have to learn is this: <?php include ("my_file") ?> . That's even easier than a script tag. Are you absolutely sure your host doesn't offer PHP? That would make it a very unusual hosting plan in 2009. Some have it, but you need to ask for it to be switched on. It's really worth checking out. (If your plan is on a Windows box, they might have ASP instead. Different code, but just as easy.)

Link to comment
Share on other sites

  • 2 weeks later...

Ignore me. I suppose the previous comment was on what the OP could use if he got an ASP.NET server.

Link to comment
Share on other sites

  • 2 weeks later...
Guest Icewalker

or you could just use the frameset and frame tags in html. Look it up on the w3 site, its what I use for exactly what you are talkign about.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...