Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Including a file into HTML

Status
Not open for further replies.

arlequin

Programmer
Sep 21, 1999
232
UY
Hi, people!<br>
<br>
Many thanx to the people who aswered my questions!<br>
<br>
Here's another: I want to include (like in C) a file that have a lot of HTML tags that I use in several pages.<br>
I don't wanna write them down every time i need them, so I used &lt;!--#include .... --&gt; tag in ASP pages but it didn't work on HTML,<br>
<br>
is there any solution to this?
 
The &lt;!--#include .... --&gt; tag will not work on HTML files unless the server has been directed to parse .htm or .html files for server-side includes. By default most web servers will only parse includes in .shtml files.
 
I should have done this on my own web page, but by the time I had found out about it, it was too late. This will make it incompatible with IE because MS has yet to implement layers into its browser (layers are incredibly flexible), but you could do something like this: <i> &lt;ilayer src=&quot;webpage.html&quot;&gt; </i><br>
The <i>webpage.html</i> would be the file containing the html you want in all your pages. <p>REH<br><a href=mailto:hawkdogg@crosswinds.net>hawkdogg@crosswinds.net</a><br><a href= by Linux</a><br>Learn Linux and Leave out the Windows :)
 
that is true about the ilayer, but MS has implemented the iframe.<br>
<br>
you might be able to do something like this:<br>
<br>
&lt;script language=&quot;javascipt&quot;&gt;<br>
if ((navigator.appName.toLowerCase().indexOf('micros')!=-1)&& (parseInt(navigator.appVersion)&gt;=4)){<br>
document.write('&lt;iframe src=\&quot;_url_goes_here_\&quot;&gt;&lt;/iframe&gt;');<br>
} else <br>
if ((navigator.appName.toLowerCase().indexOf('netscape')&&<br>
(parseInt(navigator.appVersion)&gt;=4)){<br>
document.write('&lt;ilayer src=\&quot;_url_goes_here_\&quot;&gt;');<br>
}<br>
<br>
&lt;/script&gt; <p>theEclipse<br><a href=mailto: > </a><br><a href=robacarp.webjump.com>robacarp.webjump.com</a><br>
 
arlequin-<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;Please explain your question a little more fully...I think I may have a great solution for you; but I'm not sure if I'm right as to what you're wanting to do (are you wanting to load a {similar to a} libray {i.e. *.DLL} file into your page for ease of coding?). <p>-Robherc<br><a href=mailto:robherc@netzero.net>robherc@netzero.net</a><br><a href= shared.freeservers.com/searchmaster.html>SearchMaster Interface...11-in-1</a><br>Wanting to learn Assembler; please e-mail me any tutorials or links for it that are useful to you :)
 
robherc<br>
<br>
I just wanna include HTML coding into another HTML page because I have a header and a footer to include into my pages all over the site and don't wanna change one by one!!<br>
<br>
It's like a Constant value in porgramming stuff, you know!!<br>
<br>
can you help me?
 
&nbsp;&nbsp;&nbsp;&nbsp;Yes...if anyone in here can remember how to LINK to a .JS file off the top of their head (I'm not remembering it @ the moment)...all you'd have to do is write a .JS file with 3 functions; one calls <i>document.writeln()</i> to write the header HTML to the page; the other calls <i>document.writeln()</i> to write the footer of the page. (for this example, I'll say you named the functions <i>writeHeader()</i> and <i>writeFooter</i>).<br>
&nbsp;&nbsp;&nbsp;&nbsp;Now; in each of your pages, just call <i>writeHeader()</i>; then call <i>document.writeln(&quot;</i>HTML coding for this page goes here<i>&quot;)</i>; then, finally, call <i>writeFooter()</i> to add the footer to the end of your page....this should all be done via JavaScript between the <i>&lt;head&gt;</i> & <i>&lt;/head&gt;</i> tags of your page source....with the linking tag being BEFORE the script that calls the functions.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HOPE THIS HELPS! :) <p>-Robherc<br><a href=mailto:robherc@netzero.net>robherc@netzero.net</a><br><a href= shared.freeservers.com/searchmaster.html>SearchMaster Interface...11-in-1</a><br>Wanting to learn Assembler; please e-mail me any tutorials or links for it that are useful to you :)
 
&lt;script LANGUAGE=JAVASCRIPT src=&quot;yourfile.js&quot;&gt;<br>
&lt;/script&gt;<br>
<br>
Robherc is right, however the most simple and direct solution is still to use server-side includes. The Javascript solution relies completely on the browsers, some of which might have Javascript turned off.<br>
<br>
If you have administrator access to the server or if you can get the administrator to do this, I would suggest setting it up to parse server-side includes in .html files. You can even set it up so that .html files are parsed while .htm files are not.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top