include code in html

Discussion in 'HTML & Website Design' started by freebanner, Jun 15, 2009.

  1. #1
    Does anyone know how to use the include command in a HTML file? I can make it work in php but the <!--#include file="filename"--> doesnt seem to work when i use it in HTML, any ideas?

    <!--#include file="filename"-->
    Code (markup):
    does not work

    adding an extra space after the filename?

    <!--#include VIRTUAL="/filename.shtml" -->
    Code (markup):
    or
    <!--#include file="/filename.shtml" -->
    Code (markup):
    is that the right code?

    i rename my html to shtml?
     
    freebanner, Jun 15, 2009 IP
  2. qazu

    qazu Well-Known Member

    Messages:
    1,834
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    165
    #2
    You can't have server side includes in HTML as HTML runs on the client and not the server. It works in PHP because PHP runs on the server. HTML on the other hand ignores anything between <!-- and -->
     
    qazu, Jun 15, 2009 IP
  3. freebanner

    freebanner Active Member

    Messages:
    727
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    70
    #3
    so is there a way to include code from another file? if i rename the file to .shtml will that work?
     
    freebanner, Jun 15, 2009 IP
  4. hanx

    hanx Peon

    Messages:
    72
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    why dont you try php? if that support ur webspace?

    in that case u can simply include codes with this line.
     
    hanx, Jun 15, 2009 IP
  5. sujata

    sujata Member

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #5
    hi, try this

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

    and on .htaccess file (which is on your root directory) add this line, then only SSI will work on server:

    AddHandler server-parsed .html

    this will translate HTML file as SHTML, then only you SSI will work.

    Hope this will help.
     
    sujata, Jun 15, 2009 IP
  6. deonix

    deonix Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    No you cant include files in HTML, sorry but you need to switch to PHP.
     
    deonix, Jun 15, 2009 IP
  7. sujata

    sujata Member

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #7
    yes he can use the include file in HTML, that is why i suggested him with proper code. I have used it alot time on my websites and my clients websites. if you go to my site from my signature link, it's a live example of it.

    SO IT'S POSSIBLE
     
    sujata, Jun 15, 2009 IP
  8. hanx

    hanx Peon

    Messages:
    72
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    why dont u change only the pages u want the dynamic content to appear.. converting to PHP wont take that much of a time anywys...
     
    hanx, Jun 16, 2009 IP
  9. freebanner

    freebanner Active Member

    Messages:
    727
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    70
    #9
    ok so i edit the .htaccess file by adding that line? wont that slow down the loading of other html pages that dont have an include?
     
    freebanner, Jun 16, 2009 IP