Reputation: 21
i have a problem in adding iframe in my website EAADHAR, i want to add this website eaadhaar.uidai.gov.in in iframe of my site but when i add this iframe on my site it could not show anything its show blank page, if i add uidai.gov.in in iframe then its my website shows correctly this website in iframe, so at that time what can i do to add eaadhaar.uidai.gov.in to my site in iframe please solve my problem
working code
<html>
<body>
<iframe src="https://uidai.gov.in" width="600" height="400" >
</iframe>
</body>
</html>
Not working Code
<html>
<body>
<iframe src="https://eaadhaar.uidai.gov.in" width="600" height="400" >
</iframe>
</body>
</html>
Upvotes: 1
Views: 239
Reputation: 180004
The second, non-working URL is sending a header indicating it should not be iframed.
$ curl -I https://eaadhaar.uidai.gov.in
> HTTP/1.1 200 OK
> Date: Sat, 30 Apr 2016 18:06:54 GMT
> Server: Apache-Coyote/1.1
> X-Frame-Options: SAMEORIGIN
> ...
That X-Frame-Options
value tells your browser to only allow websites on the same domain name to iframe it. Any other site is forbidden from doing so.
Upvotes: 0
Reputation: 2756
Ok I got your problem. All you need to do is add the protocol it follows to make sure that doesn't mess-up with a multi-level subdomain.
Try the following code:
<html>
<body>
<iframe src="https://eaadhaar.uidai.gov.in" width="600" height="400"></iframe>
</body>
</html>
If something is not working, let me know.
UPDATE
The server sets the
X-Frame-Options
header to explicitly stop you embedding the site in a frame. There is nothing you can do about this - if the server sets that header your browser will not display the content.
The only thing I can think of is to proxy an AJAX request for the url, then look at the headers, and if it doesn't have X-Frame-Options
, then show it in the iframe
.
Upvotes: 1