A really great method is use jQuery AJAX. The parent frame would look like this:
<iframe src="iframe_load.php" style="width: 100%; height: 100%;"></iframe>
The iframe_load.php file would load the jQuery library and a JavaScript that attempts to load the destination URL in an AJAX GET:
var the_url_to_load = "http://www.your-website.com" ;
$.ajax({
type: "GET",
url: the_url_to_load,
data: "",
success: function(data){
// if can load inside iframe, load the URL
location.href = the_url_to_load ;
},
statusCode: {
500: function() {
alert( 'site has errors' ) ;
}
},
error:function (xhr, ajaxOptions, thrownError){
// if x-frame-options, site is down or web server is down
alert( 'URL did not load due to x-frame-options' ) ;
} });
IMPORTANT The destination must have contain the "Access-Control-Allow-Origin" header. Example in PHP:
HEADER( "Access-Control-Allow-Origin: *" ) ;