SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2002
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to include other HTML docs

    What methods are available to include other HTML documents? I'd like to know all that are out there, but I'd really like to know if there are some simple, elegant ones.

    For example, I don't want to re-write the HTML on every single one of my pages for the header, footer, left navigation etc. I would like that HTML to be in one file so it can easily be changed later, affecting my entire site.

    I'll start off (with some not-so elegant solutions, which is why I posted this question):


    1) insert an externally-linked JavaScript script into the HTML page where you want the generic HTML to output. In the JavaScript script, have a whole bunch of document.writes that just print out the HTML. For example

    html code here
    <script language="JavaScript" src="externalGenericHeader.js"></script>
    more html code here

    2) use frames. This is obviously very debated, and I want a better solution than this.

    3) Can an HTML "object" element be used? WC3 claims it can, but I can't get it to work with a basic example using IE 5.5.

  2. #2
    SitePoint Enthusiast
    Join Date
    Jun 2002
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    4) Use server side includes (SSI). If your server is SSI enabled, you can write

    <!--#include file="myfile.html" -->

    into an HTML document and it will insert myfile.html. That's great, but how do you enable a server to support SSI?

  3. #3
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,067
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The best way of doing this by far is to use some form of server side solution. In PHP:
    Code:
    <?php include('header.html'); ?>

  4. #4
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ColdFusion:
    <cfinclude template="pagename.html">
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  5. #5
    SitePoint Enthusiast
    Join Date
    Jun 2002
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, I agree a server-side solution is the best, but many times I don't have control over the server and these solutions aren't available.

    Still, I would like to know about them. What are other technologies that are comparable to PHP? ASP, JSP?

  6. #6
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The main server-side languages are PHP, ASP, ColdFusion and JSP. There are variants of these as well.

    You could always use javascript like you mentioned.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  7. #7
    SitePoint Member
    Join Date
    Jun 2002
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    shtml

    You can use the <!--#include file="nav_menu.html" --> and name all of the file you use this in .shtml. I haven't found a server yet that this doesn't work on. Window or Unix.

  8. #8
    SitePoint Addict ThomasAesir's Avatar
    Join Date
    May 2002
    Location
    Sydney, Australia
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Recommendation

    3) Can an HTML "object" element be used? WC3 claims it can, but I can't get it to work with a basic example using IE 5.5.
    I just tested that as well and it didn't work, then I noticed that it says "Recommendation" on w3.org's page. I guess Server side is the only way.
    Thomas Oeser - Blueprint Software
    Web Scripting Editor v 5.2 One cool Web editing tool.
    3dcomputergraphics.com Coming Soon!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •