Forum Moderators: open

Message Too Old, No Replies

.JS file killing outside web sites

         

stcrim

8:36 pm on Nov 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



We have a simple pop-behind that we offer to other web sites that's called from a .js file. We always recommend that they include that file just above the last body tag so their page can load before it pops.

Not everyone takes our advice - recently the server went down and in effect stopped a lot of web sites from loading.

Is there a way to force the javascript to timeout and allow the sites to load if our server is down?

Any thoughts?
-s-

HocusPocus

2:36 am on Nov 20, 2003 (gmt 0)

10+ Year Member



I don't think this can be done with Javascript without amending the code on the other web sites that use the pop-up. If thats not a problem you could use the JS Image object.

I think that most browsers support two event handlers onload and onerror that could be used to check whether an image from a your server is loadable and react to it.

<SCRIPT>
var testServer= new Image();
testServer.onload = function(){//pop up pop-up}
testServer.onerror = function(){//doSomeOtherStuff server, try another }
testServer.src = 'http://site/testserver.gif';
</SCRIPT>

So the if image loads you can call you javascript that opens the pop up, otherwise do nowt, or call another server.

[Not tested]

trifi

10:58 pm on Nov 25, 2003 (gmt 0)

10+ Year Member



TESTED, I have a similar function on my website. This does work, however it might be karma since you are using the unethical pop-up ad scheme.
GOOD LUCK!