Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't show some websites in iframe tag

Tags:

html

http

iframe

I am trying to develop a page in which I can show more than 3 website at a time, as below:

<ul>
   <li>
      <iframe src="http://www.facebook.com/" /><p> iframe is not supported</p>
   </li>
   <li>
      <iframe src="http://www.yahoo.com/"></iframe>
   </li>
   <li>
      <iframe src="http://www.google.co.in"></iframe>
   </li>
</ul>

The problem is that it shows yahoo.com and google.co.in, but does not display Facebook in the iframe.

like image 278
Nikhil Sharma Avatar asked Jul 12 '11 11:07

Nikhil Sharma


People also ask

Can websites block IFrames?

To prevent misuses of iFrames, you can block them from websites using the security parameters for Internet Explorer or Firefox, and with a plugin for Google Chrome.

Why iframe is not recommended?

Iframes Bring Security Risks. If you create an iframe, your site becomes vulnerable to cross-site attacks. You may get a submittable malicious web form, phishing your users' personal data. A malicious user can run a plug-in.

Do IFrames work on all browsers?

The iframe element is supported by all modern desktop and mobile browsers.


2 Answers

You have to check for HTTP response header X-Frame-Option of those sites. if its value is "DENY or SAMEORIGIN", then you can not load those website in the iframes.

DENY = No one can load the website in iframe. Even the same domain page wont be able to load. SAMEORIGIN = only a page which is in same domain can load this website in iframe.

like image 121
Fire-Hox Avatar answered Sep 22 '22 12:09

Fire-Hox


Since some websites have decided to disable embedding them in iframes theres nothing you can do with pure html solutions. You could create a serverside script (in PHP) that pulls the target site via your webserver and then use the html etc.

The only way I can think of that would enable you to check wether the site has loaded is to search the iframe for a specific element that exists on the target website (for example a div with a specific id or class on the Facebook's front page). The reason would be that different websites can handle being embedded into iframes differently and while some might display some content, some may display nothing etc and the only way to be sure is to check for real elements.

like image 25
zatatatata Avatar answered Sep 21 '22 12:09

zatatatata