/    Sign up×
Community /Pin to ProfileBookmark

Read and display contents of .txt file using Javascript

Hi,

On click of a button called “result”, I want to read and display a text file (which is present in my local drive location say: [B]C:test.txt[/B]) using java script function and display the test.txt file contents in a HTML text area.

I am new to java script,can anyone suggest the code for java script function to read and display the contents of .txt file in a HTML text area as in the code section :-

[CODE] <textarea rows=”4″ cols=”50″>
Server Status to be displayed
</textarea>[/CODE]

?

Thanks and regards
Deb

[CODE]<!DOCTYPE html>
<html>
<head>
<meta charset=”utf-8″>
<link href=”style.css” rel=”stylesheet” type=”text/css”>
</head>
<div id=”wrapper”>

<div id=”tabContainer”>
<div id=”tabs”>
<ul>
<li id=”tabHeader_5″>Status</li>
</ul>
</div>
<div id=”tabscontent”>
</div>
<div class=”tabpage” id=”tabpage_5″>
<button type=”button” onclick=”alert(‘Hello world!’)”>server</button>
<textarea rows=”4″ cols=”50″>
Server Status to be displayed
</textarea> </div></html>[/CODE]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@deathshadowMay 18.2014 — You cannot do that without a server to feed you the file via HTTP, and then to do so you would need to use an AJAX call to retrieve it...

well... wait, no, that's not ENTIRELY true, you could use framesets, the deprecated and no business on a website IFRAME, or the OBJECT tag to show it, but that would be a very ugly and likely not all that useful approach.
×

Success!

Help @Deb73268 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...