Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show google.com in an iframe?

Tags:

html

I am trying to put google.com into an iframe on my website, this works with many other websites including yahoo. But it does not work with google as it just shows a blank iframe. Why does it not render? Are there any tricks to do that?

I have tried it in an usual way to show a website in an iframe like this:

<iframe name="I1" id="if1" width="100%" 
 height="254" style="visibility:visible" 
 src="http://www.google.com"></iframe>

The google.com page does not render in the iframe, it's just blank. What is going on?

like image 654
Bala Avatar asked Jan 02 '12 12:01

Bala


People also ask

Can you put Google in an iframe?

Google Custom Search no longer supports using an iframe to host a custom search engine on your page. To host your search engine on your own page (and ensure that you always have the most up-to-date features), you must add the Google Custom Search code to your site.

Can you put any website in an iframe?

HTTPS. Websites that begin with https can in most instances be embedded as iFrames. The exception to this is where the original website does not allow itself to be embedded.


1 Answers

The reason for this is, that Google is sending an "X-Frame-Options: SAMEORIGIN" response header. This option prevents the browser from displaying iFrames that are not hosted on the same domain as the parent page.

See: Mozilla Developer Network - The X-Frame-Options response header

like image 116
Andreas Koch Avatar answered Sep 18 '22 03:09

Andreas Koch