Mystery: How does Google do cross-domain iframe communication?
Posted
by Shraga
on Stack Overflow
See other posts from Stack Overflow
or by Shraga
Published on 2010-06-15T21:55:43Z
Indexed on
2010/06/15
22:02 UTC
Read the original article
Hit count: 145
Hi everyone,
When you host Googles web search element on a page, a div is created which incorporates an iframe which points to a Google adsense ads page. However, if there are no ads for the specific query, Google somehow changes the class on YOUR domain to render the div (and iframe) invisible.
They are NOT using postMessage, as it also works in IE7. They are also not using the fragment identifier method, as no hash appears in the url. So how do they do it?
To check what I'm saying just put the following into a regular html page:
<!-- Google Custom Search Element -->
<div id="cse" style="width:100%;">Loading</div>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load('search', '1');
google.setOnLoadCallback(function(){
new google.search.CustomSearchControl().draw('cse');
}, true);
</script>
and then do a search for "cars" (or anything else that will definitely have ads) and then for "wzxv", which has no ads...
© Stack Overflow or respective owner