Load Facebook into an iframe - html

I can't load facebook into an iframe, in a web page like the following one:
<html>
<head>
<!-- some stuffs here -->
</head>
<body>
<!-- some stuffs here -->
<iframe src="http://www.google.com" frameborder="0">
</iframe>
</body>
</html>
I've tested it with other websites and it seems to load without problems for instance for wired.com, but not for facebook.com...
Can anyone explain me why?
I'm using Google Chrome and Safari, if needed.
It seems to be as if Google blocks iframe loading of its page.

If you use Firebug or Google Chrome's developer console, you can see the following error
Refused to display document because display forbidden by X-Frame-Options.
X-Frame-Options
DENY
The page cannot be displayed in a frame, regardless of the site attempting to do so.
SAMEORIGIN
The page can only be displayed in a frame on the same origin as the page itself.
Here is another related stackoverflow question
Overcoming “Display forbidden by X-Frame-Options”

Google and Facebook are using a X-Frame-Options in the HTTP response header to avoid the content being loaded in a iFrame.
The X-Frame-Options HTTP response header can be used to indicate
whether or not a browser should be allowed to render a page in a
or . Sites can use this to avoid clickjacking
attacks, by ensuring that their content is not embedded into other
sites.
Source: https://developer.mozilla.org/en/The_X-FRAME-OPTIONS_response_header
I don't think it is possible for you to override this setting.

Related

How to have Amazon website iframed in our website

I m trying to add amazon site in my website using iframe. But it fails by giving me the message as www.amazon.com refused to connect..
However other websites are working fine for the same iframe code.
iframe code:
<iframe src="https://www.amazon.com" width="800" height="600"></iframe>
Any help on explaining this mystery and possibly helping me add the amazon site as iframe is greatly appreciated.
I tried out your embed code in Chrome and saw the following error:
www.amazon.com refused to connect.
It means that the origin server does not authorize you to show this content inside an iframe.
The amazon product details page request returns the following response header:
X-Frame-Options: SAMEORIGIN
The X-Frame-Options HTTP response header can be used to indicate whether or not a browser should be allowed to render a page in a <frame>, <iframe>, <embed> or <object>. Sites can use this to avoid click-jacking attacks, by ensuring that their content is not embedded into other sites.
The added security is provided only if the user accessing the document is using a browser that supports X-Frame-Options.

Trying to get an embedded weblink or iframe to display another website

I'm trying to get a web link to display a website but I keep getting a "workplace.facebook.com refused to connect." in my display.
I tried doing an iframe and also the embed code and both display the same thing.
<!DOCTYPE html>
<html>
<body>
<embed src="https://workplace.facebook.com" style="width:500px; height:
300px;">
</body>
</html>
The output should be the main website of workplace Facebook which will be displayed on TVs around my work. The reason why I need this to work like this is so I can refresh the page after 20 minutes and have it so it automatically scrolls down slowly. These expectations are not the problem just the web link not displaying.
Some websites do not allow external hosts to display their websites inside an iFrame, they block these requests using an X-frame Options message of SAMEORIGIN which only allows them to be displayed on sites with the same domain as the website itself.
Facebook, for example, won't allow Iframes from anywhere but facebook.com
If you use the inspect element on most modern browsers you should be able to see an error message similar to this:
Refused to display 'https://www.work.facebook.com/' in a frame because
it set 'X-Frame-Options' to 'sameorigin'.
It means that the HTTP server at workplace.facebook.com send some HTTP headers to tell web browsers like Chrome to allow iframe loading of that page (https://workplace.facebook.com) only from a page hosted on the same domain (workplace.facebook.com).

Iframe embedded content not loading

I am using an <iframe> HTML tag on my page e.g. to embed content from YouTube:
<iframe src="https://www.youtube.com/embed/DnPQNOq8x2s"></iframe>
However the content is not loaded.
In Firefox nothing is shown. In Chrome, a message like "Request blocked by an extension" is shown.
What is blocking the embedded iframe content and how can I get it to load and be shown?
This is probably due to the Content Security Policy HTTP response header.
If your HTTP framework or server is configured to insert this header into the response, you should make sure that you set the frame-src directive for it:
Content-Security-Policy: frame-src *.youtube.com; (or equivalent for any site you want to embed)
The documentation for your HTTP server or framework should specify how to configure this.

iframe contents cant appear in Firefox

Below is my code:
<div style="border: solid 1px #000000; margin: 5px;">
<iframe src="http://www.w3schools.com" width="100%" height="300px" scrolling="yes"><p>Your browser does not support iframe.</p></iframe>
</div>
Contents of iframe works well in chrome but not in firefox. I've disabled add-ons but my iframe is still empty. Can anyone please help me?
If you are trying to add this Iframe on a SSL-encrypted website (https://), it won't work any more since Firefox 23 because Mozilla has decided to blocked all unencrypted content on encrypted websites (for example http-iframes on https-websites).
You can change this behaviour in your own Firefox installation by typing about:config in the address bar and setting security.mixed_content.block_active_content to false.
But that won't help you for all other FF23-visitors on your website.
As of 05/2018, the iframe lead is denied by browser due to X-Frame-Options header set to 'sameorigin'.
Tested the page with Firefox and getting blank iframe.
Here is what console says:
Load denied by X-Frame-Options: https://www.w3schools.com/ does not permit cross-origin framing.
Why that?I'll give Chrome console a chance, here's what it says:
Refused to display 'https://www.w3schools.com/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.
Basically, X-Frame-Options header (do not confuse that with CORS), is set to 'sameorigin', that means that the browser is allowed to display the iframe content only if embedded in same domain and same protocol (https://www.w3schools.com/ is not sameorigin of http://www.w3schools.com/).
Here are some docs aboiut x-frame-options:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
I don't know if its related but when I try to request w3schools by c# it responses 503 forbidden error. So they may use something to prevent showing up on iframes, etc. Facebook has similiar restrictions, you cannot display their likebox iframe unless you log in.
Why no one has mentioned CORS yet?
FROM mdn
Cross-Origin Resource Sharing (CORS) is a mechanism that uses
additional HTTP headers to let a user agent gain permission to access
selected resources from a server on a different origin (domain) than
the site currently in use. A user agent makes a cross-origin HTTP
request when it requests a resource from a different domain, protocol,
or port than the one from which the current document originated.
An example of a cross-origin request: A HTML page served from
http://domain-a.com makes an src request for
http://domain-b.com/image.jpg. Many pages on the web today load
resources like CSS stylesheets, images, and scripts from separate
domains, such as content delivery networks (CDNs).
For security reasons, browsers restrict cross-origin HTTP requests
initiated from within scripts. For example, XMLHttpRequest and the
Fetch API follow the same-origin policy. This means that a web
application using those APIs can only request HTTP resources from the
same domain the application was loaded from unless CORS headers are
used.
This means that the websites you are trying to enter from the iframe are set to deny requests from your site or others (if not all).
I had the same issue. For me the cause was a trailing slash at the end of the url.
Doesn't work:
<iframe src="http://example.com/some/sub/folder/"></iframe>
Works:
<iframe src="http://example.com/some/sub/folder"></iframe>
You need to have source file of iframe on localhost.
Firefox and Chrome doesn't display this iframe:
<iframe src="https://www.yourdomain.com/form.html"></iframe>
Works:
<iframe src="/form.html"></iframe>

Remove insecure content from the page

I want to remove insecure content from site
I added facebook social networking box by using following GWT code in HTMLPanel
< iframe width='244' height='242' class='fb-fan-box' src='https://www.facebook.com/connect/connect.php?id="+ FacebookConstants.FB_DUBLIN_PAGE_ID+ "&connections=10&stream=0&css=https://www.supergroupers.com/facebook.css' frameBorder='0' scrolling='no' allowTransparency='allowtransparency'>
but when i run above code in browser it internally adds following css file which is insecure
< LINK rel=stylesheet type=text/css href="http://external.ak.fbcdn.net/fbml_static_get.php?src=https%3A%2F%2Fwww.supergroupers.com%2Ffacebook.css&appid=106562422725875&pv=1&sig=52d2643d471dad5f75d528ba4ea74dcb&filetype=css">
Is there any why to change that http to https
Thanks
but
You should realize that adding content from any other external domain is in itself a security and privacy issue. If you are building a website that warrants https, you should NOT be including content from facebook.
Second, the issue you describe is a problem with facebook. They should be using protocol relative urls, and they are not. Nothing you can do to fix it, unless facebook provides a https version of their site that has a different url.