I'm trying to embed some random sites in an iframe. I'm getting this error:
Refused to display document because display forbidden by X-Frame-Options.
I'm willing to respect their wishes and not embed it, but I'd like to be able to detect that this is set, so that I can try and reload another page. Is there an easy to way to do this in Javascript?
You can do it either using CURL server side or using AJAX request. Either way, the idea is that you make a request to the website in question and simply check whether the response contains
X-Frame-Options
.