Sign in to follow this  

[web] External HTML Files

This topic is 4380 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a menu system that uses javascript heavily and is a large bit of code. And every webpage is going to use this menu. So instead of inserting it in the html code for every page can I have maybe some sort of external html file. Sort of like a .js file. Or if my code uses a href tags and div tags would I be able to use document.write with javascript and still be able to use css. So then I maybe be able to keep the menu in another file.

Share this post


Link to post
Share on other sites
If it's going to run off a CD, you could still write a program which will process the includes once, and use that the generate the pages which you'll use on the CD at runtime.

Then you'll only have to maintain the menu once regardless of how many times it will appear.

Mark

Share this post


Link to post
Share on other sites
Quote:
Original post by Supaflyfrank
sadly I dont everything must be ran off of a cd. And the person who is using the cd probably didnt install php on their computer.
Keep in mind that most Windows XP installations prohibit scripts to run from the local filesystem.

Share this post


Link to post
Share on other sites
Quote:
Original post by markr
If it's going to run off a CD, you could still write a program which will process the includes once, and use that the generate the pages which you'll use on the CD at runtime.


Bingo.


Grab a copy of M4, rename your files from .html to .html.in, then create a macro definition file containing something to the effect of:

define(`HTML_MENU`, `
menu item 1
')


Then put the string "HTML_MENU" in your HTML files where you want the menu to appear, e.g.:


HTML_MENU
<div id="content">




Then run m4 with:
m4 menu.m4 myfile.html.in > myfile.html


The result is a file called myfile.html with the menu inserted. You might want to keep the input files in a separate directory so they don't get included on the CD.

It's pretty easy to figure out. Be sure to keep the manual handy, and make sure you read through the first three sections to begin with. It'll take about 10 minutes at the most.

If you need something more powerful, look into Apache Forrest.

Share this post


Link to post
Share on other sites
doing so will it cause the html file being included anyway? I am trying to seperate it to save from downloading the same code over and over again. So will it just cause the code to be copied to the new file?

Share this post


Link to post
Share on other sites

This topic is 4380 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this