Cross Domain AJAX Calls and Iframe Communication How To
I set out to write a short tutorial about cross domain ajax calls and communication between iframes using url hashes (fragments), but I found this great tutorial by Michael Mahemoff covering the subject inside and out.
It is important to note that the code on his demo uses window.location.hash, although it seems this practice should currently be avoided because of a known open bugs in the way Firefox URI-decodes document.location.hash when getting its value (could be considered an expected behavior and not a bug, but still different than any other browser). Facebook’s code uses substring on pathname, and it seems to work cross browser. Facebook also have on their wiki a nice visual explanation of how it works:

Until the HTML 5 postMessage is widely adopted, we will have to keep using this somewhat of a hack, but it works, that’s what’s important.
About this entry
You’re currently reading “Cross Domain AJAX Calls and Iframe Communication How To,” an entry on Life Scaling
- Published:
- 6.7.09 / 9am
- Category:
- Browsers, Javascript, LAMP, Programming
- Tags:
- ajax, communication, cross domain, facebook, fragment, hash, HTML 5, iframe, postMessage, xd, xd_receiver
Follow me on Twitter: @orensol
- Hey #AWS, how about improving EBS? Maybe change underlying hardware to SSD, and make it more predictable? http://j.mp/gRG2b9
- @sebastianstadil it is indeed beautiful. It really depends on your use case and space to put it. I don't like when a printer crowds my desk.
- @sebastianstadil get one with builtin wifi (like hp1102w). Then you can throw it off wherever it fits around the house/office.
- Facebook Engineering Blog is one of the most incredible things to read on the Internet. http://j.mp/e7gFjg
- @dvirsky hehe, I read it as two different girlfriends, which made your tweet much more heart warming.

I am Oren, and this is my blog. I am a techie entrepreneur, co-founder & CTO of
1 Comment
Jump to comment form | comments rss [?] | trackback uri [?]