0

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

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

4
  • Using PHP - yes. Using JavaScript - no, not without a server-side proxy. Which one do you want to use? What is your situation? Commented Oct 1, 2011 at 13:40
  • I know nothing about server-side proxies so PHP will be fine :) Commented Oct 1, 2011 at 13:41
  • Curl would be a way Commented Oct 1, 2011 at 16:38
  • If this where possible then yo could read people's email from sites like gamil. Obviously this is not allowed. Commented Oct 2, 2011 at 2:29

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

And there is no way to bypass that?
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.
0

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

3 Comments

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.
then you could find a way to grab the source in JavaScript here: 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: en.wikipedia.org/wiki/Same_origin_policy
Thank you, but the page is on different server.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.