Skip to content

Instantly share code, notes, and snippets.

@getify
Created March 24, 2011 17:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save getify/885526 to your computer and use it in GitHub Desktop.
Save getify/885526 to your computer and use it in GitHub Desktop.
function xdomainajax() {
var win;
if (document.location == "otcsandbox.com") {
var content = "<html><body><scr"+"ipt>document.domain='otcsandbox.com';</scr"+"ipt><scr"+"ipt src='http://wheretogetjqueryfrom.com/jquery.js'></scr"+"ipt></body></html>";
var iframe = document.createElement("iframe");
document.body.appendChild(iframe);
win = iframe.contentDocument ? iframe : iframe.contentWindow ? iframe.contentWindow : iframe;
var doc = iframe.contentDocument ? iframe.contentDocument ? iframe.contentWindow ? iframe.contentWindow.document ? win.document;
doc.open();
doc.writeln(content);
doc.close();
}
else {
win = window;
}
win.jQuery.ajax(....);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment