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 1039037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:03:01+00:00 2026-05-16T15:03:01+00:00

I have an <iframe> whose src points to a plain text file (not HTML).

  • 0

I have an <iframe> whose src points to a plain text file (not HTML). The text gets loaded and displayed on screen, but seems to be hidden to JavaScript.

In other browsers, iframe.contentWindow.document.body.innerText is enough to get it for you, but IE returns an empty string in that case.

Is there a way that IE can access the text inside the file without involving a server?

  • 1 1 Answer
  • 1 View
  • 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-16T15:03:01+00:00Added an answer on May 16, 2026 at 3:03 pm

    You can read this file using XmlHttpRequest. If the browser can read it, so can XmlHttpRequest.

    /* Read a file  using xmlhttprequest 
    
    If the HTML file with your javascript app has been saved to disk, 
    this is an easy way to read in a data file.  Writing out is 
    more complicated and requires either an ActiveX object (IE) 
    or XPCOM (Mozilla).
    
    fname - relative path to the file
    callback - function to call with file text
    */
    function readFileHttp(fname, callback) {
       xmlhttp = getXmlHttp();
       xmlhttp.onreadystatechange = function() {
          if (xmlhttp.readyState==4) { 
              callback(xmlhttp.responseText); 
          }
       }
       xmlhttp.open("GET", fname, true);
       xmlhttp.send(null);
    }
    
    /*
    Return a cross-browser xmlhttp request object
    */
    function getXmlHttp() {
       if (window.XMLHttpRequest) {
          xmlhttp=new XMLHttpRequest();
       } else if (window.ActiveXObject) {
          xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
       }
       if (xmlhttp == null) {
          alert("Your browser does not support XMLHTTP.");
       }
       return xmlhttp;
    }
    

    Call the readFileHttp(fname, callback) using the iframe.src property for the fname parameter.
    The callback parameter should be a function that does whatever you want with the result.

    Something like this:

    var myIFrame = document.getElementById('iframeIdGoesHere');
    readFileHttp(myIFrame.src, function(result){
        //process the result
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following html in a page: <div> <iframe src=http://google.co.in style=width:200px;height:200px> </iframe> <iframe
I have this piece of HTML: <div class=embed> <iframe width=300 height=200 frameborder=0 allowfullscreen= src=http://www.youtube.com/embed/123456></iframe>
I have the following code: <html> <head> <script src=http://www.google.com/jsapi type=text/javascript></script> <script type=text/javascript> google.load(jquery, 1);
i know i can have iframe in a html page, say parent.htm, and i
I have an iframe that looks like this: <iframe id=iframe2 ...> #document <html>...</html> </iframe>
I have this iFrame in my parent window... <iFrame src=http://theirdomain.com id=Post_iFrame></iFrame> Then I have
I have an iframe which lets say that it contains the following text: <h1>
http://jsfiddle.net/fJkBU/1/ That's my code. Basically, I have an iFrame whose source may change. I
I have an iFrame that when loaded stretches his whole length without scrollbars. After
I have a screen where I need to show pdf/html .So I am making

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.