Thread: Load text dynamically in straight HTML?

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

    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:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  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
    Registered User
    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, 06:21 PM
  2. Moving to the next structure array
    By mattz in forum C Programming
    Replies: 2
    Last Post: 11-30-2001, 03:43 PM
  3. Structure problem
    By mattz in forum C Programming
    Replies: 10
    Last Post: 11-30-2001, 01:19 PM
  4. displaying text files, wierd thing :(
    By Gades in forum C Programming
    Replies: 2
    Last Post: 11-20-2001, 05:18 PM
  5. Outputting String arrays in windows
    By Xterria in forum Game Programming
    Replies: 11
    Last Post: 11-13-2001, 07:35 PM