Load text dynamically in straight HTML?

This is a discussion on Load text dynamically in straight HTML? within the A Brief History of Cprogramming.com forums, part of the Community Boards category; O.K. This may be a stupid question, but here goes: I want to load an external file to supply the ...

  1. #1
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,638

    Load text dynamically in straight HTML?

    O.K. This may be a stupid question, but here goes:

    I want to load an external file to supply the text for a given HTML element. I thought I could do something like:

    <h1 src = "offsite.txt"></h1>

    But that doesn't work. Anyone know how to do that?
    Code:
    if( numeric_limits< byte >::digits != bits_per_byte )
        error( "program requires bits_per_byte-bit bytes" );
    24bbs.cpp

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    That can't be done (AFAIK) in pure html, since html is executed on the client side. You have to use asp, php or some other server-side script.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    That Creepy Network Guy DeepBlackMagic's Avatar
    Join Date
    Feb 2003
    Posts
    265
    Look up SERVER SIDE INCLUSIONS.
    Code:
    <!--#include virtual="/path/to/some/text/file.txt" -->
    This is one example that generally works on apache. Dont forget to make sure the SSI parser recognises your file! (Rename to .SHTM / .SHTML / .SSI or whatever your server wants)

    EDIT: If you want to go PURE html, you MIGHT try the object tag, although i dont generally use them, so i cant vouch for their effectiveness.

    Code:
    <OBJECT data="file_to_include.html">
    Warning: file_to_include.html could not be included.
    </OBJECT>

  4. #4
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    It could be done with an inline frame... (or regular frames for that point, but those are silly)
    Away.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Validating the contents of a char buffer
    By mattz in forum C Programming
    Replies: 3
    Last Post: 12-09-2001, 05:21 PM
  2. Moving to the next structure array
    By mattz in forum C Programming
    Replies: 2
    Last Post: 11-30-2001, 02:43 PM
  3. Structure problem
    By mattz in forum C Programming
    Replies: 10
    Last Post: 11-30-2001, 12:19 PM
  4. displaying text files, wierd thing :(
    By Gades in forum C Programming
    Replies: 2
    Last Post: 11-20-2001, 04:18 PM
  5. Outputting String arrays in windows
    By Xterria in forum Game Programming
    Replies: 11
    Last Post: 11-13-2001, 06:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21