In my localhost, I use the following JavaScript to create an iframe
with src
and add it to the document:
$('#preview').html('<iframe src="http://google.com/"></iframe>');
IFrame shows, but not content. In firebug, this is simple:
<iframe src="http://google.com/"> <html> <head></head> <body></body> </html> </iframe>
When I execute $('iframe').attr('src','http://google.com/');
on the console, the browser loads (says "Waiting for google.com ..."), it seems to update the contents of the iframe. But then again, it is empty.
If I installed it on a local page, the content will load.
Is it because of the same origin policy? I am not so informed about this. I did some google search and I'm confused because some sites say that it is ok to include an iframe with src that does not belong to your own domain, and some say that this is not possible.
By the way, since I'm still testing on localhost, will this work if I upload it to the server somewhere? (but src iframe will still be in a different domain)
reference
source share