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

  • SEARCH
  • Home
  • 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 931499
In Process

The Archive Base Latest Questions

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

In the below code how can i make it load the file into a

  • 0

In the below code how can i make it load the file into a textarea where textarea path is parent.a.frame_name1.document.form_name1.textarea_name1

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Local File I/O</title>
<script type="text/javascript">
<!-- // Begin
var ForReading = 1,
    ForWriting = 2,
    ForAppending = 8;
var objFSO = new ActiveXObject("Scripting.FileSystemObject");

function checkText(fld, btn) {
    btn.disabled = false;
    fld.onkeypress = null;
    return true;
}

function checkFile(obj, div, btn, btn2, fld) {
    div.innerHTML = '<p><b>File:</b><br><b>Size:</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Last Modified:</b></p>';
    btn.disabled = true;
    btn2.disabled = true;
    fld.value = '';
    fld.onkeypress = new Function("return checkText(" + "document." + fld.form.name + "." + fld.name + "," + "document." + btn2.form.name + "." + btn2.name + ")");
    //
    // if (obj.value.indexOf(":") != 1) {
    // alert("Local file name must include a drive letter.");
    // return false;
    // }
    var ary = obj.value.split("\\");
    if (ary.length < 2) {
        alert("Local file name must include a path.");
        return false;
    }
    if (!/(\.txt)$/i.test(obj.value)) {
        alert("Local file name must include the '.txt' extension.");
        return false;
    }
    //
    try {
        objFile = objFSO.GetFile(obj.value);
    } catch (e) {
        if (e.message != "File not found") {
            alert(e.message);
            return false;
        } else {
            try {
                if (confirm(obj.value + "\n" + "does not exist. Click 'Ok' to create it.")) {
                    objFile = objFSO.CreateTextFile(obj.value);
                    objFile.Close();
                    objFile = objFSO.GetFile(obj.value);
                } else {
                    return false;
                }
            } catch (e) {
                alert(e.message);
                return false;
            }
        }
    }
    fileSpecs(div, btn);
    objFile = null;
    return true;
}

function fileSpecs(div, btn) {
    if (objFile.Size > 0) {
        btn.disabled = false;
    } else {
        btn.disabled = true;
    }
    var str = '<p>';
    str += '<b>File:</b> ' + objFile.Path + '<br>';
    str += '<b>Size:</b> ';
    if (objFile.Size < 1024) {
        str += objFile.Size + ' bytes';
    } else {
        str += (objFile.Size / 1024).toFixed(1) + ' Kbytes';
    }
    str += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
    str += '<b>Last Modified:</b> ' + objFile.DateLastModified;
    str += '</p>';
    div.innerHTML = str;
}

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;
}

function saveFile(btn, obj, div, fld, btn2) {
    btn.disabled = true;
    objFile = objFSO.GetFile(obj.value);
    objStream = objFile.OpenAsTextStream(ForWriting);
    objStream.Write(fld.value);
    objStream.Close();
    objStream = null;
    objFile = objFSO.GetFile(obj.value);
    fileSpecs(div, btn2);
    objFile = null;
    fld.value = '';
    fld.onkeypress = new Function("return checkText(" + "document." + fld.form.name + "." + fld.name + "," + "document." + btn.form.name + "." + btn.name + ")");
    return true;
}
// End -->
</script>
</head>

<body>
<center>
<form name="myForm" onsubmit="return false;">
<table width="720">
<tr>
<td colspan="4">
<div id="fileSpec">
<p><b>File:</b><br><b>Size:</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Last Modified:</b></p>
</div>
</td>
</tr>
<tr>
<td colspan="3" width="580" align="center" valign="top">
<textarea rows="25" name="fileArea" cols="70"
onkeypress="return checkText(this, btnSave);"></textarea> </td>
<td rowspan="2" width="140" valign="top"><p>This is a simple demonstration of
a browser-based local text file editor.&nbsp; Begin by clicking the <b>Browse</b>
button to select an existing text file from your local hard drive.&nbsp;
(In the Browse dialog, you may type in a new file name if
desired.)&nbsp; The selected file information is then displayed at the
top of the page.&nbsp; For an existing file, click the <b>Load</b>
button next.&nbsp; After editing, click the <b>Save</b> button to
complete the demonstration.</p></td>
</tr>
<tr>
<td align="left">
<input type="file" name="fileName" size="50"
onchange="return checkFile(this, document.getElementById('fileSpec'), btnLoad, btnSave, fileArea);"> </td>
<td align="center">
<input type="button" name="btnLoad" value="Load" disabled
onclick="return loadFile(this, fileName, document.getElementById('fileSpec'), fileArea);"> </td>
<td align="center">
<input type="button" name="btnSave" value="Save" disabled
onclick="return saveFile(this, fileName, document.getElementById('fileSpec'), fileArea, btnLoad);"> </td>
</tr>
</table>
</form>
</center>

</body>
</html>

(Also inform me whenever and what u have edited in my post , sad others coming and editing my post)

  • 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:30:43+00:00Added an answer on May 15, 2026 at 8:30 pm

    Replace the lines

        if (!/(\.txt)$/i.test(obj.value)) {
        alert("Local file name must include the '.txt' extension.");
        return false;
    }
    

    with

        if (!/(\.txt|\.htm|\.html)$/i.test(obj.value)) {
        alert("Local file name must include the '.txt', '.htm' or '.html' extension.");
        return false;
    }
    

    For your convenience, it now takes htm-files as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 477k
  • Answers 477k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Take apc.php from APC distro and open it in browser. May 16, 2026 at 5:10 am
  • Editorial Team
    Editorial Team added an answer If you are using the Import / Export wizard, when… May 16, 2026 at 5:10 am
  • Editorial Team
    Editorial Team added an answer You will need to do "classpath magic". Since there is… May 16, 2026 at 5:10 am

Trending Tags

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

Top Members

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.