Results 1 to 7 of 7

Thread: Help me load specific content from a remote page by using JavaScript

  1. #1
    Join Date
    May 2008
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Help me load specific content from a remote page by using JavaScript

    Help me load specific content from a remote page using JavaScript, please.

    I need to load specific text value from a page located on a remote domain and replace that value in my HTML code.

    I can load the remote page in a small 1x1 pixels iframe and I have a regular expression which I can use to find the content I need. I have little clue, however, on how to use JavaScript to extract the content from the page in the iframe.

    Point me, please to some tutorials which can show me how to do it.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,920
    Thanks
    43
    Thanked 3,187 Times in 3,151 Posts
    Blog Entries
    12

    Default

    This may be illegal, copyright infringement. It is also an illegal operation, in that modern browsers will not allow communication between pages on different domains via javascript. It can't be done with javascript alone.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    May 2008
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thank you for your reply.

    Yes, JavaScript alone can't do that, that's why I intend to load the page contents inside an iframe and save it in a variable.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,920
    Thanks
    43
    Thanked 3,187 Times in 3,151 Posts
    Blog Entries
    12

    Default

    The use of an iframe is immaterial, the page inside it is still on another domain.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    May 2008
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    I doubt that because the moment the page is loaded by a user's browser it is already located on their hard drive.

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,920
    Thanks
    43
    Thanked 3,187 Times in 3,151 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by Dellius View Post
    I doubt that because the moment the page is loaded by a user's browser it is already located on their hard drive.
    Don't. It is, but javascript cannot access the user's hard drive either. It isn't a question of the values not being 'available'. It is a question of security measures in modern browsers. In the old days you could just use:

    Code:
    iframe_element_object.document.innerHTML
    Where iframe_element_object is the iframe fetched via document.all or document.getElementById (or any method that 'gets' it as page element, as opposed to as a window frame) and parse that string using your favorite method to get what you are after. Or even:

    Code:
    iframe_element_object.document.getElementById('some_id').innerHTML
    to query a particular element on the page's innerHTML. But this is no longer allowed or supported, except for pages that are both on the same domain.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. The Following User Says Thank You to jscheuer1 For This Useful Post:

    Dellius (05-16-2008)

  8. #7
    Join Date
    May 2008
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thank you for clarifying this for me, jscheuer1.

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
  •