www.webdeveloper.com
Results 1 to 5 of 5

Thread: Read Content of other HTML page to current HTML Page using Javascript

  1. #1
    Join Date
    Jul 2012
    Posts
    5

    Read Content of other HTML page to current HTML Page using Javascript

    I think before I start off with the question I'll explain the situation... It'll make more sense that way (hopefully).

    I've been asked to create a dashboard HTML page that will include charts generated in other HTML pages.

    Each of the charts in those HTML pages (there are approximately 6 different pages) are only loaded when that particular HTML page is loaded, once that particular HTML page is closed, the chart no longer exists. I was thinking if whether it is possible to read the content in any one of those particular HTML pages and re-creating the chart and displaying it in the dashboard.htm page.

    The first thing I was going to try and do was to grab a single line from a table in that HTML page and write it to the new dashboard htm page. But after much failed google search attempts I've resorted to actually seeking professional help in a forum. So my first question is, is it possible using JavaScript to read the content in any of those particular HTML pages in the dashboard html page?

    Maybe something like this?

    html page name: chocolate.htm
    HTML Code:
    <html>
    <head></head>
    <body>
    <p id="test">Some text here</p>
    </body>
    </html>
    Code:
    var thePage = document.open('chocolate.htm');
    
    alert(thePage.getElementById('test'));

  2. #2
    Join Date
    Mar 2012
    Posts
    202
    You may use AJAX to get what you need accomplished. http://www.w3schools.com/ajax/ajax_example.asp

  3. #3
    Join Date
    Jul 2012
    Posts
    5
    hmm... I did think about that but I was trying to avoid going down that path.

    I have actually found a new way of doing what it is I want to do through iframes. It's still not working as I want it to but I'm tweaking it and hopefully should get it to run.

    The only problem I'm having now is referencing the charts that are generated in those other pages. I believe its called DOM HTML or something?

  4. #4
    Join Date
    Mar 2012
    Posts
    202
    Please post the source code of what you have so far and I'll help you use AJAX in order to get this thing going

  5. #5
    Join Date
    Jul 2012
    Posts
    5
    Hi Gray,

    Sorry for the incredibly delayed response. Just thought I'd let you know that I've figured it out and I've got it all working.

    I solved the problem by using iframes.

    Thanks very much for your help though.

    Ash.

Thread Information

Users Browsing this Thread

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

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