[Javascript] script source problem

Peter-Paul Koch gassinaumasis at hotmail.com
Thu Apr 26 08:35:39 CDT 2001


>I'm having a tricky problem calling my 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?

Nothing. The script is unavailable.

>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.

Well, you can do that. Suppose there's a function myFunc() in the included 
script and you call it from your page. Then do

if (self.myFunc)
    myFunc()
else
   alert('Sorry, other server is down')

So first check if the function myFunc() exists, and only then execute it. If 
it doesn't exist something is horribly wrong and you should notify the user 
of the problem.

ppk

>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,
>
>Greg Merritt
>
><script language=Javascript src=http://anotherserver/myscript.js>
></script>
>
>
>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>http://www.LaTech.edu/mailman/listinfo/javascript

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.





More information about the Javascript mailing list