Forum Moderators: open

Message Too Old, No Replies

Calling a script from another server that is down

JS on a 3rd party server that is down..

         

klauslovgreen

8:03 pm on Jun 29, 2005 (gmt 0)

10+ Year Member



I'm having a tricky problem calling a javascript source in the <script> tag.

The problem is, I'm calling the source from another server (and the javascript has to be on this other server).

What can I do if that other server goes down?

I don't want users to experience errors or strange behavior. At the very least, it would be nice to give them an error message or simply skip the script.

I've read all the documentation, and nothing worked (supposedly code placed between the script tags will execute on error, but it doesn't work if the
other web server is down).

I'm hoping someone on this list has found a workaround.

Thanks,

Cheers
Klaus

Ex:
<script src="http://someserver/script.js" type="text/javascript"></script>

kaled

9:21 am on Jun 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can you call the script from an IFrame? This would probably isolate any problems but you would have to test it to be sure.

Kaled.

klauslovgreen

10:04 am on Jun 30, 2005 (gmt 0)

10+ Year Member



Thanks for the suggestion - it does not work out though as the JS is displaying a dynamic sized advert advert.

I tried <object> too with no luck. Loading the JS at the end of the page is not an option either sadly..

Any other ideas?

Cheers
Klaus

j4mes

10:13 am on Jun 30, 2005 (gmt 0)

10+ Year Member



Add a variable at the start of the called script file, something like:

var exists = "yes";

then something like this in the page loading it:

<script type="text/javascript">
var exists = "no"; // default until external loaded
</script>

<script src="http://someserver/script.js" type="text/javascript"></script>

<script type="text/javascript">
if (exists == "no") {
// it didn't load, better do something else!
}
</script>

J.

klauslovgreen

11:33 am on Jun 30, 2005 (gmt 0)

10+ Year Member



Thanks - looks like a resonable solution - trying simulate various situations to check it works

Cheers
Klaus