Reputation: 8895
Google Chrome 23 and Firefox 18 is driving me nut.
I have a page, in which i have an iframe.
When a button click, I want the iframe to open http://images.google.com
The problem is the iframe will try to visit http://images.google.com, but as soon as it get a redirect instruction (which http://images.google.com is issueing), it halt and the page won't be rendered. Why is that? Any solution?
Here is a snippet demonstrate that issue:
<iframe id="panel" style="height: 800px; width: 100%" sandbox="allow-scripts" src="http://images.google.com">
</iframe>
Upvotes: 4
Views: 20112
Reputation: 26474
It is a browser security issue, known as Click-jacking prevention, part of which is to check for a HTTP response header, X-Frame-Options. This header can take the values DENY
, SAMEORIGIN
, or ALLOW-FROM
origin, which will prevent any framing, prevent framing by external sites, or allow framing only by the specified site, respectively.
Simply put, when this http header is there, it prevents the site from rendering in a <frame>
or an <iframe>
. Since 2009 this http header is implemented in most browsers including IE8+, Safari, Firefox, Chrome, and Opera.
Here are the headers from images.google.com
, SAMEORIGIN
means that the address could only be rendered inside an iframe when it is being surfed through google.com
Upvotes: 6