Welcome Here And Thanks For Visiting. Like Us On Facebook...

EXEIdeas – Let's Your Mind Rock » HTML-CSS-PHP-JavaScript / PHP Codes » How To Show Second Website If First Website Is Down In Iframe?

How To Show Second Website If First Website Is Down In Iframe?


If you want to set a web page in your IFRAME tag then you can simple add it but if a visitor visit your website and see that your IFRAME is empty and there is not website there then it might hurt him then here comes the problem because no one want to hurt his visitor.

Not when you adding an IFRAME then you are not sure about it that that web page that you added will be online or not when a visitor will visit your page then here is the solution to add two web pages in one IFRAME and the second one will be shown when first one will be down.

For this purpose you have to use PHP CURL-Request that checks that your web page is online or not and responding or not. You can make a condition that will first check the 1st-Web-Page and if that one is down then it will show 2nd-Web-Page. The code is simple and in PHP.

Table of Contents


1.) Simple And Easy Code.
2.) Easy To Add And Customize.
3.) PHP Code.
4.) CURL-Request Function Used.
5.) Custom Time To Check First Web Page.

   echo '<iframe src="1st-Web-Page"></iframe>';
   echo '<iframe src="2nd-Web-Page"></iframe>';
 function isDomainAvailible($domain, $timeout ='30') // Change 30 With Your Desired Time To Check First WebPage
  if(!filter_var($domain, FILTER_VALIDATE_URL))
  $curlInit = curl_init($domain);
  $response = curl_exec($curlInit);


1.) Change 1st-Web-Page with your first check IFRAME source.
2.) Change 2nd-Web-Page with your second IFRAME source if first one is down.
3.) Change 30 with your desired time to check first WebPage in sec.

Recommended For You:
Fix A DIV When Scroll Horizontally And Allow To Scroll When Scroll Vertically?

Last Words:

This is what we have and shared in easy steps for newbies so that they can easily know how it works. Stay with us because we are going to share more codes that will make your coding more easy for you. If you liked it then share it and be with us to get next tutorial. If you have any problem then feel free to ask us. We will help you with what we can or have.

You Like It, Please Share This Recipe With Your Friends Using...

Be the first to write a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *