Load an External File

Posted on 2004-11-11
Last Modified: 2010-04-06
Please can you tell me the code to load text from an external file onto my page.
My website is currently set up with 20 links on.

Named: webpagea
and so on....

If you click on the first link it adds text?webpagea to the end of my url, it then opens another page which splits the text in the link to "webpagea" once it has done this it loads the image webpagea.jpg,
if your clicked the second link it would load webpageb.jpg and so on....

I want it so it loads text from a txt file in the same way so if i click on the first link it will load webpagea.txt and if i click the second link it loads webpageb.txt and so on....

How do I do this??
Thanx in advance
Question by:intalex
    LVL 3

    Expert Comment

    Not too sure what you mean by this - perhaps place a link or a more detailed explanation of what you are trying to do.

    If you trying to import a page (like a menu) into another page, this may work for you (depending on your host-server, environment)

    <!--#include file="myFile.htm"-->

    will include the myFile.htm into where ever it is in the page.

    (If it doesn't work try changing the extention of your page to shtm - (the page that is importing not the page that is being imported.)

    Let me know more info and I will try and give you an answer.

    Author Comment

    What more do you need?

    There is a page with 20 links on and each link goes to the same website.
    If you click on link a it will add ?webpagea to the end of the link.

    It will load the page and the page splits up the link to "webpagea" this is held as a variable.
    It should then load webpagea.txt on the website....

    Thats what i dont know how to do load the text as it may not be webpagea all the time if you clicked on link b it would need to load webpageb.txt
    LVL 3

    Expert Comment

    Okay, I was trying to get you to reword it as the following line was a bit confusing:
    It will load the page and the page splits up the link to "webpagea" this is held as a variable

    But now I understand - you want to get the querystring value of the page name, normally the querystring comes in a key/value pair so it would be more like ?webpage=a which would be accessible as the variable webpage.

    There are multiple ways to do this depending on your server platform. If you don't know or have access to server-side scripting languages like ASP or PHP then it will be a lot more difficult.

    If you don't ,I wonder whether you have to do it like you have written. You could use frames to have the same result - as follows:

    <!-- index.htm -->

    <FRAMESET cols="200, *">
       <FRAME name="menu" src="frame1.htm">
       <FRAME name="content" src="pagea.htm">
          <P>This document uses frames which your browser does not support</P>      

    <!-- frame1.htm -->

    <a href="pagea.htm" target="content">Page A</a><br>
    <a href="pageb.htm" target="content">Page B</a><br>
    <a href="pagec.htm" target="content">Page C</a><br>

    If you want to do it another way, ideally you'll have ASP which would allow you to properly import a text file in to the page.

    LVL 3

    Accepted Solution

    Another way is to generate the frame or page dynamically using JavaScript.

    If the menu links are as follows:
    <a href="frameset.html?page=webpagea.htm">webpagea</a>

    <script type="text/javascript" language="JavaScript">
    function getPage() {
         if(! {
         } else {
    <frameset cols="200,*" onload="javascript:getPage()">
         <frame id="menu" src="menu.htm">
         <frame id="content" src="index.htm">
               <p>Your browser is really old and does not support frames</p>

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
    Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System ( introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
    Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now