0

I have an iframe on my website that displays different site.

Is it possible to grab & store/save source of the iframed site?

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Wordpressor
  • 7,173
  • 23
  • 69
  • 108

2 Answers2

1

The same-origin policy in the browser will prevent you from accessing the internal content of a div loaded from another domain.

Jason Dean
  • 9,585
  • 27
  • 36
  • And there is no way to bypass that? – Wordpressor Oct 01 '11 at 17:38
  • I hope not :) It would a security problem if you could. The only place I have ever seen it possible to get around it is in something like an Adobe AIR application, and there you need to create a "bridge" that must be supported by the iframe parent and the child. – Jason Dean Oct 01 '11 at 18:23
0

You can always just $iframeSource = file_get_contents("http://iframe-source-url/"); it.

Dvir
  • 5,049
  • 1
  • 23
  • 32
  • I believe this is not what I want to achieve. I need to grab the data that specific, exact user gets from the iframed site. I'm not sure if it is possible, seems like security hole to me. – Wordpressor Oct 01 '11 at 13:44
  • then you could find a way to grab the source in JavaScript here: http://stackoverflow.com/questions/139118/javascript-iframe-innerhtml and then store it with an AJAX call back to your PHP script. You should be aware of the fact that you can only do this for pages residing on the same server. Read about it here: http://en.wikipedia.org/wiki/Same_origin_policy – Dvir Oct 01 '11 at 13:54
  • Thank you, but the page is on different server. – Wordpressor Oct 01 '11 at 13:58