PDA

View Full Version : Load text dynamically in straight HTML?



Sebastiani
09-24-2003, 01:36 AM
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?

Magos
09-24-2003, 02:12 AM
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.

DeepBlackMagic
09-24-2003, 02:28 AM
Look up SERVER SIDE INCLUSIONS.


<!--#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.



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

confuted
09-24-2003, 06:52 AM
It could be done with an inline frame... (or regular frames for that point, but those are silly)