• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 162
  • Last Modified:

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
0
intalex
Asked:
intalex
  • 3
1 Solution
 
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now