Click to See Complete Forum and Search --> : External Script Error


DiLDoG
01-12-2003, 05:19 AM
I've got this script on my page
Rank: <b><script src='http://www.clanbase.com/cbrank.php?cid=265426&lid=405&type=js'></script>

But sometimes the clanbase server is overloaded and the script only loads half and gives an error.
How can I detect this error and display "N/A" en stead of an error message?

khalidali63
01-12-2003, 08:39 AM
I know a hack you can probably use.
create an image object at the end of your external fileand in your body tag imageName.onload = some action here
imageName.onerror = error handling routine here.

Hope this helps

Khalid

DiLDoG
01-12-2003, 08:47 AM
???

khalidali63
01-12-2003, 09:22 AM
Ohhhhkk here you go.

first oof all at the very bottom of your .js file that you are importing, write the following code.

function errorHandler (evt) {
if (this.src.indexOf('resources') != -1){
alert("The js file is not loaded")
}
}
var validationImg = new Image();

//validationImg.onload = loadHandler;
validationImg.onerror = errorHandler;

then right below the import statement in the HTML page

put the following code
<script>
validationImg.src =ImageLoacation.gif
</script>

Hope this helps

Khalid

DiLDoG
01-12-2003, 04:25 PM
Uhm I can't edit the external javascript