views:

136

answers:

2

Hi I am trying to grab a div from another website using JS.

I have an iframe that loads a page from an external site, I want to grab a div that contains a list so I can style it myself and put it on my site.

Any ideas, would be greatly appreciated.

Thanks.

+7  A: 

Most browsers won't allow you to mess with other websites in iframes via javascript on purpose, because it's an obvious security issue.

Tom Dalling
+1 I would say all browsers
flybywire
Is there any way just to grab a div and echo it on your own page, so I am not actually making any changes to their page ?
Joe
You need to use a proxy script so that the browser reads the page from your own server. You can't even read the HTML from an external site using script - you can load it into an iframe and display it verbatim, but you can't see it from script at all.
RichieHindle
Thanks for that, I hadnt thought of that method.
Joe
+2  A: 

As Tom points out, you can't do this because of browser security. You can work around it by installing a proxy script on your server, so that the browser loads the external page via your server.

RichieHindle