View Full Version : Only having one menu to change without frames?
Jeff122185
08-14-2002, 03:09 AM
Personally, I dislike frames and I've never attempted to use them. That aside, I use tables for my menu, but I have to put the same code in each of my pages and then change it whenever I make any additions or adjustments to it. Is there any way to make one menu and edit that only and somehow implement it into all my pages? (Kinda like how you can make a .css file and link to it instead of rewriting it on all your pages.) Thanks for the help.
Use an external javascript file.
The most basic would be document.write.
IE..
<html>
<head>
</head>
<body>
<table ...ETC>
<tr>
<td><SCRIPT language="javascript" type="text/javascript" src="menu.js"></SCRIPT></td>
</tr>
</table>
</body>
</html>
**********************
and in the external file ...
document.write('<a href="link1.html">Link one</a><br><a href="link2.html">Link two</a>');
************************
Obviously save as "menu.js"
Any change you make to the external file will automaticly update every page.
Hope this helps
Tonz:cool:
justame
08-14-2002, 03:28 AM
jef...
just a checkout® this link from the ol' waforum just a rchives® :O)))
http://www.codingforums.com/ubb/Forum5/HTML/004224.html
/me just a looks® @ ton...heyyy where did you just a come® from??? lol...twas just a no® reply before /me went back to the ol' forum...hehehe...
just a ps® to jef...
/mes link shows ya howww to do it the just a ssi® way
Jeff122185
08-14-2002, 04:25 AM
Hmmm, I have a significant amount of code (since most of my pages are made of nested tables) in my menu. Can I just write
document.write('
<Lots of code lots of code lots of code>
<Lots of code lots of code lots of code>
<Lots of code lots of code lots of code>
<Lots of code lots of code lots of code>
');
or would I have to do a document.write for each line?
Roy Sinclair
08-14-2002, 07:43 PM
You have to do it the hard way OR you can cheat and use a service like this (http://www.wsabstract.com/script/script2/jstohtml.shtml) which will take a chunck of html and make the javascript to write it for you.
lacrypta
08-15-2002, 02:31 AM
just use Sever Side Includes (ssi)
<!--#include file="NAme of File" -->
and save ur document as .shtml
instead of .html
lacrypta
08-15-2002, 02:31 AM
ans make sure ur host supports ssi
Jeff122185
08-15-2002, 03:35 AM
Well, my web host doesn't support SSI. As for the useful link Roy provided me, using an external JS file seems to ignore the class attributes... I think I read somewhere about changing the . in front of classes to a # and then changing class to id... but that didn't seem to work...
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.