Skip to content Skip to sidebar Skip to footer

Going Beyond The Iframe

I am trying to get an iframe B communicate with site A. I've searched and searched and every thing I read says it's impossible if they are of different domain (the iframe src is co

Solution 1:

If you want the two iframes to communicate and you say one is on a different subdomain but the same top-level domain, you can do inter-frame scripting. See http://ajaxian.com/archives/how-to-make-xmlhttprequest-calls-to-another-server-in-your-domain.

The trick is to get page A and B to both set

document.domain = 'SameTopLevelDomain.com';

and the browser will then let the pages communicate (eg grab data from the other, call functions, etc).

However if the two pages are on different domains altogether, you'd have to take the server-side proxy approach as answered earlier.

Solution 2:

You can't cross iframe boundaries for security reason, it would be straightforward to steal your login credentials to any site if that would be possible.

However you can make server side proxy, which would redirect every query from iframe to ads servers. That way your iframe could actually have source in the same domain (or subdomain)

Solution 3:

There is a way to do cross-domain communication using iframes, described in an answer to Resizing an Iframe based on content.

Many ad-serving companies serve their banners on your site via iframes, and use the technique outlined in the answer above to ensure that the iframe can expand to the full required size of the creative.

Solution 4:

Maybe my answer Cross-site AJAX requests will help you.

Post a Comment for "Going Beyond The Iframe"