Results 1 to 2 of 2

Thread: Read and display contents of .txt file using Javascript

  1. #1
    Join Date
    May 2014

    Read and display contents of .txt file using Javascript


    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: C:\\test.txt) 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 :-
     <textarea rows="4" cols="50">
            Server Status to be displayed

    Thanks and regards

    <!DOCTYPE html>
    <meta charset="utf-8">
    <link href="style.css" rel="stylesheet" type="text/css">
    <div id="wrapper">
      <div id="tabContainer">
        <div id="tabs">
            <li id="tabHeader_5">Status</li>
        <div id="tabscontent">
    	   <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>

  2. #2
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center