View Full Version : JavaScript (I think) question
picch
02-25-2007, 02:30 PM
This site that I help with uses an ads server to provide a rotating advertisement banner towards the top of the site. The problem with this is that that ads server is located on another box, so when that box is taken offline or has an unexpected problem. The main site hangs like none other because of it attempting to connect to the ads server. Is there any sort of check that I can throw into the site that will make it give up connecting to the ads server after say 2 seconds? I assume it would be some sort of javascript thing but I could be wrong.
Thanks in advanced :D
cookster
02-26-2007, 10:08 AM
What controls the banner advertisement rotation?
JavaScript: Well javascript is client side, you want to do the test connection server side, and I don't know javascript very well, but my guess is doing it through this is a little more difficult.
For PHP: If it is PHP, there is a hw_connect/hw_Pconnect which returns a true or false statement. I'm not sure the number of tries it will attempt - but if you use PHP to do a quick call to the host of the ad's and it times out you can throw up a default.
So in short here is what I assume and suggest:
I assume javascript controls the banner rotations, but if you can run java script you can probably run PHP.
Do something like this where the banner code normally goes:
<?php
if(hw_connect("127.0.0.1", 8080, username, password)){
<script stuff goes here>
else
<img src = default image>
?>
Well thats my pseudo. Hope that helps.
nlopez
02-26-2007, 02:53 PM
Where is the stall happening? Is your site actually connecting to the ad server and waiting for data, or just linking to an image at adserver.suxor.com/annoyme? If it's server side, in the PHP or ASP or whatever, there's probably a timeout value you can set when connecting to the ad server. If it's just an img link maybe you can put the size of the ads into your <img> tag so the browsers don't wait for the ad server to send them something to lay out the page.
vBulletin® v3.8.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.