user13733104
user13733104

Reputation:

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>

Upvotes: 1

Views: 15468

Answers (1)

Nayana Chandran
Nayana Chandran

Reputation: 1483

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 <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. 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!

Upvotes: 3

Related Questions