How does Google's API make cross-domain requests back to Google, when it's on your website?
|
|||
|
They get around it by dynamically injecting script tags into the head of the document. The javascript that is sent down via this injection has a callback function in it that tells the script running in the page that it has loaded and the payload (data). The script can then remove the dynamically injected script tag and continue. |
|||
|
AFAIK they use IFRAMEs. |
|||||||||||
|
Another possibility is to use the |
|||
|
The accepted answer is wrong. Ben is correct. Below is the actually iframe node pulled off a page using the Google API JavaScript Client.
Basic summary of how this works is here: http://ternarylabs.com/2011/03/27/secure-cross-domain-iframe-communication/. On modern browsers they utilize HTML postMessage to achieve communication, and on older browsers, they use a neat multiple-iframe-urlhash-read+write-combination hack. Ternary Labs have made a library which abstracts all the hacky stuff out, essentially giving you postMessage on all browsers. One day I'll build ontop of this library to simplify cross-domain REST APIs... |
|||
|