views:

31

answers:

1

Is it possible to change the source of an iframe when a link is clicked in the iFrame?

For example, my iFrame loads http://www.google.com, but when I click a link on Google.com, the source of the iFrame cannot be changed to that new URL.

Is there some way to access the iFrame location in Firefox and IE to redirect the iFrame?

Sort of like a proxy website. How are proxy sites doing this in PHP?

A: 

It's not possible to access to the content of an iframe from outside and vice versa, otherwise it would lead to a big security issue. For example, if you have access to its content or URL, it would be also possible to retrieve cookies, request parameters, input fields, etc... which can contains sensible data such as password, session id...

If you want to make a PHP proxy, your script must

  1. get the content of the requested page
  2. convert the relative URLs to absolute URLs
  3. append the proxy URL to all URLs
  4. transmit the data

But I think this method is ugly : when you use this, the URL in the address bar is never the real URL of the requested page. In my opinion, implementing a SOCKS proxy is much cleaner and easier.

Mr_Qqn