🔒 Locked
[web] External HTML Files
Advertisement
Original Post
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.
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.
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.:
<!-- stuff -->HTML_MENU <!-- content -->Then run m4 with:
m4 menu.m4 myfile.html.in > myfile.htmlThe 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.
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?
Nevermind. The answer is much simpler. Put the javascript in a separate file and put a script tag pointing to that file where you want the menu. E.g.:
<script type="text/javascript" src="mymenu.js"></script><br></pre>You might still want to eventually look into <a href="http://forrest.apache.org/">Apache Forrest</a>.</code></pre>
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement