SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    May 2006
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help please including a web page file like .txt .html etc.

    Hello, how do you include another web page file into a page using javascript?
    Another web page file such as .txt, .html etc? Please let me know, thank you very much.

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,156
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)

    including a file into a page

    You don't need javascript to do this. Although the w3c recommends using the object tag most pages Iv'e seen use an iframe. eg
    HTML Code:
    <iframe src="file.txt"></iframe>

  3. #3
    SitePoint Addict
    Join Date
    May 2006
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Isn't there any way to do it without an Iframe? Please let me know, thank you very much.

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,156
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)

    object tag

    Yes, but it can be a little tricky sometimes depending on what you're including.
    HTML Code:
    <html><head><title>Object HTML page</title>
    </head>
    <body>
    <h2>Object in HTML page</h2>
    <object data="file.html" height="75&#37;" width="98%">
    Warning: html file could not be embedded.
    </object>
    </body></html>

  5. #5
    SitePoint Addict
    Join Date
    May 2006
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks very much, do I have to make my page title say this in order for it to work? Any way to do it without changing the pages title? You've been very helpful, thank you very much for you help.

  6. #6
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,156
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)

    object tag

    No, that code is from an old test file I had when I was testing how to include different file types without the embed tag. The data, height, and width values can be what you want, as can be the HTML stuff.
    The main thing is
    <object data="file.txt"></object>
    everything else is optional, as long as it displays OK for you.


Bookmarks

Posting Permissions

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