Wednesday 21 September 2011

Coding a html page to insert a text file in the page?

i know it exists..but i'm looking to make an index.html where its coded to get maybe a %26quot;description.txt%26quot; file from the directory and show that in the .html page. this way i can have a universal html page but just change .txt files. how to do this...THANKSCoding a html page to insert a text file in the page?It's really not a great way to design a site to be honest.



But if you want to, you do need to get out of just html. SHTML can do it, as can any server side language, php is most common, and will do it much cleaner.



You can also pull off the effect in javascript, but that is the worst of the options as anyone not using javascript, which includes search engine spiders, won't see your content.



If I where you I'd go with php, it can be done very simply.



%26lt;?php require(%26quot;myfile.html%26quot;); ?%26gt;



will include %26quot;myfile.html%26quot;, if your server supports php, which most do, just rename yout file from .html to .php and stick that in where you want to do the include.



Of course to make is useful you're looking at something more like this:



%26lt;?php

if($_GET[do]== %26quot;foo%26quot;)

require(%26quot;foo.html%26quot;);

else if($_GET[do]== %26quot;bar%26quot;)

require(%26quot;bar.html%26quot;);

else

require(%26quot;default.html%26quot;);

?%26gt;



then point your links too:



index.php?do=foo

index.php?do=bar

index.php
Coding a html page to insert a text file in the page?
try going to the library and do some research on this topic.
Coding a html page to insert a text file in the page?
As far as I know you need to know JavaScript for this.
Save your .txt files as html instead but you don't have to edit anything in it.



In your index.html, use iframe to make it universal and having the contents in the iframe changed.



read up further here: http://www.w3schools.com/tags/tag_iframe.asp
You can use Server Side Includes (SSI) if you want to include things into HTML. Check if your host supports it. You can also use PHP to include plain text inside your markup, but it has to be on a server to test it.



If you don't have PHP you can go the iframe route (easiest, but save the .txt as .html) but the styleing may be tricky.



You can use AJAX (javascript) to do it.
You can use something like this to call the page:



%26lt;div id=%26quot;obj%26quot;%26gt;

%26lt;object id=%26quot;Image_Shack%26quot; type=%26quot;text/html%26quot; style=%26quot;width:790px; height:100%;%26quot; data=%26quot;http://profile.imageshack.us/user/鈥?br>
%26lt;/div%26gt;



That code embeds a page from ImageShack inside another HTML page. Adjust as needed for your page.



The div styling is:



%26lt;style type=%26quot;text/css%26quot;%26gt;

div#obj { width: 790px; margin: 2% auto; border: 5px ridge #070; }

%26lt;/style%26gt;



Ron
  • adult myspace
  • get time from datetime
  •