aF.
aF.

Reputation: 66727

Is it possible to load an external page?

How can I load an external page (ex: http://www.google.pt) to a div in my page?

I've tried html5 like this:

document.getElementById(id).innerHTML = "<iframe src='http://www.google.com' height='100%' width='100%'></iframe>";

but it doesn't load.

When I put a page from my domain, it properly loads.


How can I load an external page (from another domain) ?

Upvotes: 0

Views: 247

Answers (4)

Florian Margaine
Florian Margaine

Reputation: 60817

Loading this iframe gives this error : Refused to display document because display forbidden by X-Frame-Options.

Which means that Google doesn't allow you to do this. If you want to use Google Search on your site, you can use Google Custom Search.

Upvotes: 1

dplanet
dplanet

Reputation: 5413

You should really do this server-side, because including a page on the client-side can have bad effects. For a start, Google won't read a page loaded with an iframe.

It's a pretty cheap way to do things, does your server not support PHP?

Upvotes: 0

copenndthagen
copenndthagen

Reputation: 50750

There are some cross-domain restrictions because of which you cannot load any external site directly into an iframe on your page.

However you can try the following jQuery plugin for making cross-domain AJAX requests;

https://github.com/padolsey/jQuery-Plugins/blob/master/cross-domain-ajax/jquery.xdomainajax.js

Upvotes: 1

dead
dead

Reputation: 364

Google does not let itself be loaded from within an iframe.

Upvotes: 1

Related Questions