SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    I ♥ PHP
    Join Date
    Jul 2003
    Location
    Melbourne, Australia
    Posts
    579
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Accessing elements in another HTML file

    Hi everyone,

    I would like to retrieve some data from multiple pages and store them in an object in my Javascript funtion.

    An example, my file would check files a.html, b.html and c.html. I have created three objects in my function. For each object, I would like to retrieve the innerHTML of a certain element in each of those files. For instance:
    Code:
    PseudoCode:
    objA.data = a.html > getElementById('theElement').innerHTML;
    objA.style = a.html > getElementsByTagName('style')[0].innerHTML;
    
    objB.data = b.html > getElementById('theElement').innerHTML;
    objB.style = b.html > getElementsByTagName('style')[0].innerHTML;
    Is this possible? If so, does anyone have any pointers please?

    Thanks,
    Jordan

  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,426
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Unless you are using frames you cannot access other HTML files with JavaScript.

  3. #3
    I ♥ PHP
    Join Date
    Jul 2003
    Location
    Melbourne, Australia
    Posts
    579
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmmmm, that puts a major dampener on my project.

    Ok, can I access an XML file with Javascript? I have complete control of all data in this project, it is all coming in from a bunch of Excel files. I currently have a process in the Excel file to export all of the data in to HTML files, if I output it to XML instead can I read the data in from there? Perhaps if I load the files in to hidden frames and access them that way?

    I have a lot of data to display from many different tables, and I would prefer to take the hit and have all of the data load in once the program is launched so that it can be navigated seamlessly, rather than wait for each page to load one at a time. This is a purely internal file. I also want to use Javascript navigation and have a single HTML file. I have tried one version using iFrames and swapping the src files but it is still not as responsive as I would like.

    Any ideas?

    Thanks,
    Jordan

  4. #4
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,426
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Ajax is designed to work with XML (it's the X in Ajax). With it you can pull down the XML file and do with it as you please.

  5. #5
    I ♥ PHP
    Join Date
    Jul 2003
    Location
    Melbourne, Australia
    Posts
    579
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, need a bit of a rethink here, but I think this will work out fine. Thanks stymiee.


Bookmarks

Posting Permissions

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