OT: HTML / Javascript Question

Walter Vaughan wvaughan at steelerubber.com
Sat Mar 20 16:33:20 PST 2004


Douglas Luurs wrote:

>Is there a javascript tag that would check to see if a file exists, and if
>So open it, otherwise open a different one?
>
>Ie:
>	check for a PDF on the NAS, and display it, otherwise display a
>custom
>	404-type page.
>
>
>  
>
<script language="JavaScript"><!-
function testImage(URL) {
    var tester=new Image();
    tester.onLoad=isGood;
    tester.onError=isBad;
    tester.src=URL;
}

function isGood() {
    alert('That file exists!');
}

function isBad() {
    alert('That file does not exist!');
}
//--></script>

Obviously if it cannot load it as an image bitmap, it does not exist.
Revise your functions as needed. Your friend in all this is 
the JavaScript "OnError" functionality. Read up on "OnError".
--
Walter





More information about the Filepro-list mailing list