How to have Amazon website iframed in our website - html

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.

Related

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 refuses to display

I am trying to load a simple iframe into one of my web pages but it is not displaying. I am getting this error in Chrome:
Refused to display 'https://cw.na1.hgncloud.com/crossmatch/index.do' in a frame because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'self' https://cw.na1.hgncloud.com".
Invalid 'X-Frame-Options' header encountered when loading 'https://cw.na1.hgncloud.com/crossmatch/index.do': 'ALLOW-FROM https://cw.na1.hgncloud.com' is not a recognized directive. The header will be ignored.
This is the code for my iframe:
<p><iframe src="https://cw.na1.hgncloud.com/crossmatch/" width="680" height="500" frameborder="0"></iframe></p>
I am not really sure what that means. I have loaded plenty iframes before and never received such errors.
Any ideas?
It means that the http server at cw.na1.hgncloud.com send some http headers to tell web browsers like Chrome to allow iframe loading of that page (https://cw.na1.hgncloud.com/crossmatch/) only from a page hosted on the same domain (cw.na1.hgncloud.com) :
Content-Security-Policy: frame-ancestors 'self' https://cw.na1.hgncloud.com
X-Frame-Options: ALLOW-FROM https://cw.na1.hgncloud.com
You should read that :
https://developer.mozilla.org/en-US/docs/Web/Security/CSP
https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy
The reason for the error is that the host server for https://cw.na1.hgncloud.com has provided some HTTP headers to protect the document. One of which is that the frame ancestors must be from the same domain as the original content. It seems you are attempting to put the iframe at a domain location that is not the same as the content of the iframe - thus violating the Content Security Policy that the host has set.
Check out this link on Content Security Policy for more details.
For any of you calling back to the same server for your IFRAME, pass this simple header inside the IFRAME page:
Content-Security-Policy: frame-ancestors 'self'
Or, add this to your web server's CSP configuration.
In my case it was that the site i was embedding had a specific url for embedding content and a different url for sharing
the url i had set in the iframe was
https://site/share/2432423232
changing it to
https://site/embed/2432423232
worked for me
The same issue appears to me, don't open the page in a private window.
You can use multiple browsers if you need to log in with different users.

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>

Load Facebook into an iframe

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.