Grab Exterrnal Site Div Content

Discussion in 'JavaScript' started by BRIAN_C_C, Oct 4, 2007.

  1. #1
    Is it possible to display the <div id=""> content from an external domain/site and display it on my own... I don't want their whole page... just some reports they update weekly...
     
    BRIAN_C_C, Oct 4, 2007 IP
  2. ezpz

    ezpz Peon

    Messages:
    25
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I don't think you can interact with another website in this way, because browsers enforce a same-origin policy to prevent cross-site scripting - see http://en.wikipedia.org/wiki/Cross-site_scripting
     
    ezpz, Oct 4, 2007 IP
  3. temp2

    temp2 Well-Known Member

    Messages:
    1,231
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    150
    Digital Goods:
    2
    #3
    If you want to do this thing, you should use server languages to read URL, check to filter data you need
     
    temp2, Oct 4, 2007 IP
  4. aRo`

    aRo` Peon

    Messages:
    141
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    an approuch in javascript would be to load the external url in an iframe and then read the source code of the iframe.
     
    aRo`, Oct 5, 2007 IP
  5. phd

    phd Active Member

    Messages:
    496
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    60
    #5
    use Ajax to do so, grab the external code via php or asp, and handle that in javascript using innerHTML property. thats it!!
     
    phd, Oct 5, 2007 IP
  6. ezpz

    ezpz Peon

    Messages:
    25
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Does the external site know you want to do this, and approve? If they do, they might be willing to make it easy for you, putting the reports in a stand-alone page that you can include with a simple iFrame.

    If they don't, perhaps you shouldn't go this way. They could change the id of their div at some point, which would break your site, or they could actively block your server-side IP address if you're planning to do it server side.

    And call me old-fashioned, but it just seems wrong...
     
    ezpz, Oct 6, 2007 IP