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?
Printable View
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?
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.
Look up SERVER SIDE INCLUSIONS.
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)Code:<!--#include virtual="/path/to/some/text/file.txt" -->
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>
It could be done with an inline frame... (or regular frames for that point, but those are silly)