View Full Version : Onfilemissing

10-17-2003, 11:05 AM
How do I check if a file is missing?

<a onclick && onfilemissing( alert('file not found') );">check file</a>

Not going to use it like this at all, but I thought it would be easier to understand if I explain it like this... ;)

10-17-2003, 11:15 AM
you can do it via XMLHTTP in Javascript or better, you can customize your own HTTP 404 File not Found page and set up your webserver not to display the default 404 page but instead display the customized page.

see this sample:


10-17-2003, 11:18 AM
Thats one way, but I was trying to accomplish a for that loop until a page can't be found.

Page1.htm -> find
Page2.htm -> find
Page3.htm -> find
Page4.htm -> not find, end loop

Had one idea, but I don't know if it would work in any way, it involved onerror...

10-17-2003, 11:42 AM
If it were images you can use the Image object and use onerror and onload handlers to check for their existence. Though you can use Image object for non-image files, it would always fire onerror event even if files exist.

10-17-2003, 11:48 AM
There isn't then a proper way to do it exept on images?

10-17-2003, 12:05 PM
There's a method to do it, but it's not worth the effort.

10-17-2003, 12:30 PM
As I said in my first post, you can do it via XMLHTTP. The question here is why do you want to do such a thing.