Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    Regular Coder Doctor_Varney's Avatar
    Join Date
    Mar 2008
    Location
    Midlands, UK
    Posts
    649
    Thanks
    45
    Thanked 29 Times in 28 Posts

    Is it possible to import text into HTML?

    I was wondering if it is possible to import text, from a .txt document (or another HTML one) into my page...

    The idea would be, to keep the text of the document seperate from the HTML and just call in lumps (or paragraphs) from the sourced document.
    Reason: Well, it would make my written source material a lot easier to organise and manage.

    I've looked around the internet, and have so far not found any HTML (or CSS) properties which will allow this. So, I thought I'd ask here. Maybe you have some ideas, other than using a series of i-frames (which I'd rather not do).

    (I'm thinking there must be something, along the lines of: #div src="...", or <p src="..."></p> in order to do this?)

    But having said that, are i-frames considered bad, in the realm of Web-Standards, in the same sense that framesets, themselves, are?

    Many thanks,
    Last edited by Doctor_Varney; 11-17-2008 at 05:31 AM.
    Definition: Computer rage is a heightened physiological response with associated feelings of anger and frustration[1] resulting from using a computer or other complex electronic device. It may result in the physical assault of the computer or similar item.[2] Computer use often leads to verbal abuse and occasionally physical violence towards the object.[3] Computer rage may be caused by distress due to a hardware or software problem which the enraged person is unable to correct.

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    There isn't something in HTML only. You would need to look into PHP includes or server-side includes. You may also want to look into a CMS.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Regular Coder
    Join Date
    Nov 2005
    Posts
    329
    Thanks
    3
    Thanked 19 Times in 19 Posts
    Do you have a lot of text to import each time? Dynamicdrive has an interesting JavaScript "Switch Content Script" which switches content (images or text) in a division with a click on the relevant link. You might want to check it out at:

    http://www.dynamicdrive.com/dynamici...tchcontent.htm

    The same source gives you the reasons for avoiding frames and iFrames:
    http://www.dynamicsitesolutions.com/...s-and-iframes/

    Cheers!
    Last edited by Avril; 11-17-2008 at 07:30 AM. Reason: error

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Doctor_Varney View Post
    But having said that, are i-frames considered bad, in the realm of Web-Standards, in the same sense that framesets, themselves, are?
    both i-frames and framesets are part of the w3c recommandation which are web standards. Usualy people have other reasons then standards when they say that something "is not standard",

    best regards

  • #5
    The Apostate Apostropartheid's Avatar
    Join Date
    Oct 2007
    Posts
    3,215
    Thanks
    16
    Thanked 265 Times in 263 Posts
    I well and truly could not express more my distastes for both frames and JavaScript calling in content. Server-side includes would be the best option, and the most ubiquitous language you could do it in is PHP.

  • #6
    Regular Coder
    Join Date
    Aug 2005
    Location
    MS
    Posts
    834
    Thanks
    10
    Thanked 79 Times in 77 Posts
    Interesting. I haven't tried this code with a text file, but it should work. Probably not what you intended though.

    Code:
    <div style="margin: 0 auto; width:100%; height:400px;"><object type="text/html" data="http://Domain_Name.com/File_name.html" style="width:100%; height:100%; margin:1%;"></object></div>
    ☠ ☠RON☠ ☠

  • #7
    Regular Coder Doctor_Varney's Avatar
    Join Date
    Mar 2008
    Location
    Midlands, UK
    Posts
    649
    Thanks
    45
    Thanked 29 Times in 28 Posts
    Quote Originally Posted by Major Payne View Post
    Interesting. I haven't tried this code with a text file, but it should work. Probably not what you intended though.

    Code:
    <div style="margin: 0 auto; width:100%; height:400px;"><object type="text/html" data="http://Domain_Name.com/File_name.html" style="width:100%; height:100%; margin:1%;"></object></div>
    Thank you, Major Payne. Would that work on it's own, or would this still necessitate me learning PHP?

    Cyanlight, I can easily relate to the frames distaste although I get the impression that the people who show the most distaste for it, are often less distracted by internal design considerations, than by efficient interchanges of information across webs. This would also go for flash, I guess, though I'm not sure. The point being, that if you're looking at some projects, the visual look could be of overriding importance to whether the page makes web-standards. For some things, visual things, knowing my site was viewable without style, might be a little like being observed without trousers, in public.

    I'm improving, though not quite yet out of the woods and homefree with CSS. Granted, it's only style, not major programming, but I still feel I have a long way to go with it. I can see myself looking at a new language, next year, at this rate.

    But having said that, I will have to discover first, how much more steep of a learning curve PHP will be. How much it differs to HTML. I'm aware of it's uses in fora, for organising large quantities of data.

    Thanks,
    Last edited by Doctor_Varney; 11-18-2008 at 07:46 AM.
    Definition: Computer rage is a heightened physiological response with associated feelings of anger and frustration[1] resulting from using a computer or other complex electronic device. It may result in the physical assault of the computer or similar item.[2] Computer use often leads to verbal abuse and occasionally physical violence towards the object.[3] Computer rage may be caused by distress due to a hardware or software problem which the enraged person is unable to correct.

  • #8
    Regular Coder Doctor_Varney's Avatar
    Join Date
    Mar 2008
    Location
    Midlands, UK
    Posts
    649
    Thanks
    45
    Thanked 29 Times in 28 Posts
    I've tried the above code and it works, though styling up the actual content of the div seems not to work. Like you said, Major, probably not what I expected, but it's giving me ideas already. Many thanks!
    Definition: Computer rage is a heightened physiological response with associated feelings of anger and frustration[1] resulting from using a computer or other complex electronic device. It may result in the physical assault of the computer or similar item.[2] Computer use often leads to verbal abuse and occasionally physical violence towards the object.[3] Computer rage may be caused by distress due to a hardware or software problem which the enraged person is unable to correct.

  • #9
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Quote Originally Posted by Doctor_Varney View Post
    I've tried the above code and it works, though styling up the actual content of the div seems not to work. Like you said, Major, probably not what I expected, but it's giving me ideas already. Many thanks!
    Be sure to try it in other browsers. Browser support may be a little flaky.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #10
    Regular Coder FWDrew's Avatar
    Join Date
    Apr 2008
    Location
    Missouri
    Posts
    380
    Thanks
    38
    Thanked 45 Times in 43 Posts
    Just want to put my vote in for a php include, it does exactly what you need and will work in any browser with the tiny code below:

    PHP Code:
    <?php include("textfile.txt"?>
    This is a great way to easily update items such as your navigation and footer once you have a lot of pages up as you only need edit the text file that holds the html.

    http://us3.php.net/include/

    Best Regards,

    Drew
    Last edited by FWDrew; 11-18-2008 at 08:38 AM. Reason: Added link
    Dev-Tips.com || Employee at the Envato Network || My Portfolio

  • #11
    Regular Coder Doctor_Varney's Avatar
    Join Date
    Mar 2008
    Location
    Midlands, UK
    Posts
    649
    Thanks
    45
    Thanked 29 Times in 28 Posts
    Quote Originally Posted by FWDrew View Post
    Just want to put my vote in for a php include, it does exactly what you need and will work in any browser with the tiny code below:

    PHP Code:
    <?php include("textfile.txt"?>
    This is a great way to easily update items such as your navigation and footer once you have a lot of pages up as you only need edit the text file that holds the html.

    http://us3.php.net/include/

    Best Regards,

    Drew
    I'll certainly have a look into that, Drew. It's got me tempted now... Thankyou!

    Cheers,
    Definition: Computer rage is a heightened physiological response with associated feelings of anger and frustration[1] resulting from using a computer or other complex electronic device. It may result in the physical assault of the computer or similar item.[2] Computer use often leads to verbal abuse and occasionally physical violence towards the object.[3] Computer rage may be caused by distress due to a hardware or software problem which the enraged person is unable to correct.

  • #12
    Senior Coder effpeetee's Avatar
    Join Date
    Feb 2007
    Location
    Clapham Junction - London SW
    Posts
    4,885
    Thanks
    228
    Thanked 204 Times in 203 Posts
    Doctor. Regarding one of your earlier queries about side to side images.
    Perhaps you will find this of interest.

    The parent page is also of interest.

    A different view.

    Frank
    Last edited by effpeetee; 11-18-2008 at 02:55 PM.
    * Sources (updated: 21.11.2012.
    Using Windows 8 Professional. 64bit with HP Photosmart 5510 printer Very useful site here.

  • #13
    The Apostate Apostropartheid's Avatar
    Join Date
    Oct 2007
    Posts
    3,215
    Thanks
    16
    Thanked 265 Times in 263 Posts
    Quote Originally Posted by Doctor_Varney View Post
    Cyanlight, I can easily relate to the frames distaste although I get the impression that the people who show the most distaste for it, are often less distracted by internal design considerations, than by efficient interchanges of information across webs. This would also go for flash, I guess, though I'm not sure. The point being, that if you're looking at some projects, the visual look could be of overriding importance to whether the page makes web-standards. For some things, visual things, knowing my site was viewable without style, might be a little like being observed without trousers, in public.
    For the record, I'm a designer and have never been anything but that. But the disadvantages of using frames, like its inherent hate of accessibility and printing, outweigh its "benefits", of which I'm not exactly sure of. A web professional worth his salt will always make sure that the content is king and nothing but, so I'm not sure how visual look takes precedence. Web standards are here for a reason, and, to be honest, I've never come across a situation where standards cannot be adhered to.

    Your metaphor doesn't make much sense to me either. A page without styles is nothing like being inspected in public without trousers, because our users have x-ray goggles so you don't know when they're looking at you without trousers. Not that I would, of course...

    Back to frames, don't use them. They cannot be accessed on their own by a non-tech savvy user, are probably slower (not sure on this fact but I'm sure that server-side includes are faster) and are just generally annoying. I would vote for PHP, but simple server side includes (SSIs) are also a viable choice--but keep in mind, most people are going to get onto using PHP at some point.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •