www.webdeveloper.com
Results 1 to 2 of 2

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

Hybrid View

  1. #1
    Join Date
    May 2014
    Posts
    2

    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: 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 :-
    Code:
     <textarea rows="4" cols="50">
            Server Status to be displayed
            </textarea>
    ?


    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>

  2. #2
    Join Date
    May 2014
    Posts
    597
    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.
    Java is to JavaScript as Ham is to Hamburger.

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



Recent Articles