简体   繁体   中英

iframe banner: <? if connection timed out then

in my site I use iframe to show banner from other site. The problem is, the other site's connection seldom have problem. Now off course at that 'not so frequent' time the empty frame would appear, and it's not good. What I want is have some kind of php if..else conditional statement that can redirect it to other banner. Perhaps (logically) it would be like this:

<?php $iframe = the iframe url; $banner = the local banner url;
if ($iframe connection timed out) {$banner;} ?>

I am a 100% noob so please help p

http://php.net/manual/en/function.fsockopen.php

Will check if it is responding at all, if not don't show the iframe.

This has nothing to do with PHP. You can't have an IF else in the case the other server is replying slowly.

You can append your iframe after onload with javascript (or like google analytics does) to don't slow down your page load time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM