Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 930339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:19:05+00:00 2026-05-15T20:19:05+00:00

Using javascript, how to open a text-file or html-file from a web-page and load

  • 0

Using javascript, how to open a text-file or html-file from a web-page and load the contents in the text file or the html code to a textarea. Please Dont tell me this not possible using javsscript, it is possible but i dont know the code and my bro not coming home for a week . Example codes will be greatly appreciated. (i have already asked this question but everyone seemed to concentrate on the other part of the question.)

<html>
<body>
<form name="abc">
<textarea name="text">loaded text here</textarea>
<input type="button" onClick=""> open file
</form>
</body>
</html>

I found this in a forum , dont remember name , This is a working code but can only load text files …. now the question is how can I get it to fetch htmlcodes from a html file.

<html>
<head>

<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">


<script type="text/javascript">

var ForReading = 1, ForWriting = 2, ForAppending = 8;
var objFSO = new ActiveXObject("Scripting.FileSystemObject");

function loadFile(btn, obj, div, fld) {
objFile = objFSO.GetFile(obj.value);
objStream = objFile.OpenAsTextStream(ForReading);
fld.value = objStream.ReadAll();
objStream.Close();
objStream= null;
fileSpecs(div, btn);
objFile = null;
return true;
}

</script>
</head>

<body>
<form name="myForm" onsubmit="return false;">

<textarea rows="25" name="fileArea" cols="70"
onkeypress="return checkText(this, btnSave);"></textarea> </td>


<input type="file" name="fileName" size="50"
onchange="return checkFile(this, document.getElementById('fileSpec'), btnLoad, btnSave, fileArea);">

<input type="button" name="btnLoad" value="Load" 
onclick="return loadFile(this, fileName, document.getElementById('fileSpec'), fileArea);"> 

</form>
</body>
</html>

This is another one the coder claims it to be working but it is nt working for me , please execute this code if u hav time …if it is working please provide the complete code here.
(coded by Ancora)

<html>
<head>
<script type="text/javascript">

function init(){

var extText = window.frames.messageTxt.document.body.lastChild.lastChild.data;
extText = extText.replace(/[\r\n]/g," ");
document.forms[0].nMessage.value = extText;
}

window.onload=init;

</script>
</head>
<body>
<iframe name='messageTxt' src='txtData.txt'  style='display:none'></iframe>
<form>
<textarea name='nMessage'></textarea>
<input type="button" value="click" onClick="init()">
</form>
</body>
</html>

i guess no can do this…i had a javascript that can load htmlcode form an external html file into the textarea. But i lost that file, sad no one here has the scripting abilities to create a js function (or active x) that can do the same.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T20:19:05+00:00Added an answer on May 15, 2026 at 8:19 pm

    It’s definitely possible, using AJAX. You have to keep in mind that same-origin restrictions mean it will only work on your own domain. One way is with jQuery.get:

    EDIT: A more complete demo (see also jsFiddle demo):

    <html>
    <head>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.js"></script>
    <script type="text/javascript">
    
        function download_to_textbox(url, el)
        {
          $.get(url, null, function(data)
                           {
                             el.val(data);
                           }, "text");
        }
    
        $(function()
        {
          $('#open').click(function()
          {
            download_to_textbox("/ajax_json_echo/?foo=bar", $("textarea[name='text']"));
          });
        });
    </script>
    </head>
    <body>
        <form name="abc">
            <textarea name="text" rows="20" cols="70">loaded text here</textarea>
            <input id="open" value="open" type="button">
        </form>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 531k
  • Answers 530k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It appears the problem was hardware-related. Our client found a… May 16, 2026 at 11:45 pm
  • Editorial Team
    Editorial Team added an answer Forms cannot be nested. That's simply is not allowed in… May 16, 2026 at 11:45 pm
  • Editorial Team
    Editorial Team added an answer You need to remove the following line: if (m_pPtr) NPN_MemFree(m_pPtr);… May 16, 2026 at 11:45 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I tried to 1) load an xml file using javascript as an object, say
I have been trying, unsuccessfully, to get a HTML page to load an external
I finally succeeded in using Ajax to get SOMETHING sent from one page to
I am using the following code to open a popup window and passing the
how to triggered open/save window by using javascript?
I am using Selenium to do testing, We write our test cases in HTML
Good day. I am trying to fetch an asp.net label control's text value using
I am using a a href Click Here link in the page and if
I have an HTML page where I want to change Image & Link with
I've been learning a lot about web technologies recently and I want to put

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.