I am writing a webpage to test whether any particular website allows embedding into an IFrame.
Webservers use the X-Frame-Options header to determine whether or not they allow other websites to embed them using IFrames.
If this header is set to DENY
or SAMEORIGIN
, then the embedded IFrame cannot load the website.
If a website has X-Frame-Options
set to either one of these configurations, (such as https://google.com), then I can see this error message in the console:
Refused to display 'https://www.google.com/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.
This question is about detecting refused connections in frames (but none of the answers actually work!)
This leads me to my question:
Is there a way I can detect whether a website allows or denies frames using JQuery?