Forum Moderators: open

Message Too Old, No Replies

Equivalent of PHP include in Javascript

Want to insert footer

         

spica42

3:25 pm on Aug 2, 2004 (gmt 0)

10+ Year Member



I have a website that I didn't use a include file for the footer, so now when I have to update the footers, I need to manually change all the pages.

I know it can't be help now but I'm wondering if there's an equivalent to PHP include for javascript because I'll like to add in the codes while I'm updating the footer this time, without changing the extensions. (.html)

Any disadvantages for this javascript method? if any?

neo_brown

4:15 pm on Aug 2, 2004 (gmt 0)

10+ Year Member



Here is something I found that seems to do the job. I have not tested it!

Save it as a .js file and then call it remotely from each page.
With regard to whether there are any disadvantages?
I’m sure there are, I don’t think Google likes js at all and perhaps will not recognize your links as links in the same way that it would were they done in PHP or another server side scripting.
Having said that I am far from an expert maybe some of the more experienced members can give you a more definitive answer.

--------------------------------

document.write('<p><hr width="400" size="2" color="#000000" noshade>');
document.write('<p><font face="Verdana, Arial, Helvetica, sans-serif" size=2><b>');
document.write('<a href="html/index.html">HTML</a> ~ <a href="css/index.html">CSS</a> ~ <a href="jscript/index.html">Javascript</a> ~ <a href="webtools/index.html">Web Tools</a>');
document.write('<br><a href="tutorials/index.html">Tutorials</a> ~ <a href="designtips/index.html">Design Tips</a> ~ <a href="downloads/index.html">Downloads</a>');
document.write('<br><a href="articles/index2.html">Articles</a> ~ <a href="ebooks/index.html">E-Books</a> ~ <a href="mwdnews.html">Newsletter</a>');
document.write('<p><a href="http://" onClick="history.back()">');
document.write('<img border="0" src="images/backbut.gif" width="150" height="23"></a>');

---------------------------------------

dataKris

4:23 pm on Aug 2, 2004 (gmt 0)

10+ Year Member



Spica,

Have you considered using iframes? They are a viable option to php includes.

dataK

spica42

11:20 pm on Aug 2, 2004 (gmt 0)

10+ Year Member



iframes? what are they?

dataKris

2:59 pm on Aug 3, 2004 (gmt 0)

10+ Year Member



spica,

iframes is the abbreviation of inline frames.. just like frames, and use plain old pure HTML..

Search for 'iframes tutorial' on google and the first link that appears would give you a good general idea of how to use it..

I constantly use it when the file is in HTML and I cannot use includes.

neo_brown

4:50 pm on Aug 3, 2004 (gmt 0)

10+ Year Member



Id agree that this is definatly a better option than javascript, just ensure your crossbrowser functionality.