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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inputting html code from a seperate file

Status
Not open for further replies.

kilo3000

Programmer
Feb 13, 2004
10
CA
Hi, I would like to add html code(links) from a separate file into many other html pages (so that only this file would need to be changed to change this code in all pages). But I would also like this code to appear when view source is clicked, or more specifically I would like search engines to be able to read the included links contained in the code.

Any help on how I can accomplish this would be great. thanks!
 
kilo3000,

Modify and place the following snippet into your HTML wherever you want to include a separate HTML file:
Code:
<!--include file="links.html"-->
Your included file does not need to have [blue]<html></html>[/blue] or [blue]<head></head>[/blue] tags because your "parent" file will have them.

Hope this helps.
-Ron

We all play from the same deck of cards, it's how we play the hand we are dealt which makes us who we are. -Me

murof siht edisni kcuts m'I - PLEH
 
Thanks!

will include files be picked up by Search Engines, so that the links contained in the file included will be indexed properly?
 
I'm not positive, but I think they just appear to spiders as part of the parent HTML files.

-Ron

We all play from the same deck of cards, it's how we play the hand we are dealt which makes us who we are. -Me

murof siht edisni kcuts m'I - PLEH
 
There's another way of including a file using javascript. You would put the entire file in a text document then call it with javascript like this (the file has to be in the same directory)
Code:
<script language="javascript" type="text/javascript" 
  src="yourFile.txt"></script>
then yourFile.txt would have;
Code:
[COLOR=red]document.write('[/color]<div> or any html code you want</div>[COLOR=red]')[/color]
Where ever you put the script tags is where the html code would go in the page.
Hope this helps.

Glen
 
glenmac's approach - because it relies on Javascript run by the browser - won't be picked up by Search engines (or anybody else that surfs with JS switched off).

Darkshadeau's solution (using SSI - server side includes, read more about them at faq253-3309 & faq253-2000 ) runs on the server, so by the time the page gets to the browser or the search engine robot it'll just look like an ordinary HTML page.


-- Chris Hunt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top