Friday, July 31, 2009

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 "description.txt" 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...THANKS

Coding 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("myfile.html"); ?%26gt;





will include "myfile.html", 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]== "foo")


require("foo.html");


else if($_GET[do]== "bar")


require("bar.html");


else


require("default.html");


?%26gt;





then point your links too:





index.php?do=foo


index.php?do=bar


index.php
Reply: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...
Reply:You can use something like this to call the page:





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


%26lt;object id="Image_Shack" type="text/html" style="width:790px; height:100%;" data="http://profile.imageshack.us/user/...


%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="text/css"%26gt;


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


%26lt;/style%26gt;





Ron
Reply:As far as I know you need to know JavaScript for this.
Reply:try going to the library and do some research on this topic.
Reply: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.


No comments:

Post a Comment