Load an External File

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
            webpageb
            webpagec
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
intalexAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

weddellCommented:
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.
0
intalexAuthor Commented:
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
0
weddellCommented:
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">
  <NOFRAMES>
      <P>This document uses frames which your browser does not support</P>      
  </NOFRAMES>
</FRAMESET>


<!-- 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.


0
weddellCommented:
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>

<html>
<head>
<script type="text/javascript" language="JavaScript">
function getPage() {
     if(!location.search) {
          document.getElementById("content").src="index.htm";
     } else {
          var page=location.search.substr(1).split("&");
          document.getElementById("content").src=page[1].split("=")[1];
     }
}
</script>
</head>
<frameset cols="200,*" onload="javascript:getPage()">
     <frame id="menu" src="menu.htm">
     <frame id="content" src="index.htm">
     <noframes>
           <p>Your browser is really old and does not support frames</p>
     </noframes>
</frameset>
</html>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.