'refused to connect error when embedding a website with iframe

I was trying to embed a website (the full website) in HTML with iframe but I got an error when trying to embed the website. www.example.com refused to connect. My code:

<iframe src="https://www.example.com" title="Example"></iframe>


Solution 1:[1]

I faced the same issue while embedding a website in another website (Squarespace) 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 click-jacking attacks, by ensuring that their content is not embedded into other sites. There are three possible directives for X-Frame-Options:

X-Frame-Options: DENY
X-Frame-Options: SAMEORIGIN
X-Frame-Options: ALLOW-FROM https://toucan-springtail-bftp.squarespace.com/

I used the 3'd option and the URL after ALLOW-FROM is the URL of the website where you want to embed.

And it worked for me!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nayana Chandran