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

linking an external HTML file

Status
Not open for further replies.

greatwhitenorth98

Technical User
Apr 8, 2004
32
FR
I have a number of HTML pages that will all contain the same 50 lines of HTML code (a set of DIVs). Is there some way that I can place this code in an external file and link/include it? The code will use javascript and likely some PHP.

Thanks
 
not possible with pure html

with php, you can do it like so:

<?php
include("myIncludeFile.html");
?>



=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
 
Thanks for the answer.

Does this mean that including the file in a specific place in the <body> of the parent file, it will run as if it was actually 'written' there?
 
Ok, got it all working and now I want to make it compatible with my directory structure. Seeing as how the html script will be called by a number of other pages, I put it into the root directory. Now, when I call it from a sub-directory the links necessary (on my displayed browser page) are there (the cursor changes and the links work) but I don't see the images that I created as links.

This all worked when the file was in the same directory as the parent page file. Are the 'displayed' link images behind my background but accessible? How can I put it into the foreground to see what I am clicking?

Am I making sense?
 
Got that one, too, after a bit of mental searching...

The images were not being displayed because they were not being accessed from the proper directory. It would seem that 'include' actually brings the code into that script and any relative link is sourced at the parent page and not the directory where the included script resides. Interesting...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top