Reply to Re: checking for a file

Your name:

Reply:


Posted by Neredbojias on 05/20/06 01:09

To further the education of mankind, Eric <nospam@email.com> vouchsafed:

>>>How do i do that from javascript? Can i call it somehow? I'm in a
>>>javascript loop looking at a series of files, and if one is missing i
>>>need to break out of the loop early.
>>
>> Perhaps you should give us the full picture so we know what you're
>> trying to achieve.
>>
>> The answer to: "Is it possible to check for existence of a file from
>> a web page using javascript?" is probably no. But there may be
>> another solution. Are you able to run scripts on your web server?

> Ok, I've got some javascript code that loads images in a loop for a
> slideshow. The images are gathered from a web cam, 1 each 5 minutes so
> that i hae a history going back 2 days (This isnt published by the way
> its only for my use "at this time", i may put it public later - not
> sure yet) Anyway, its entirely possible that out of the 576 possible
> images that something changed and maybe only images 1 to 297 (or
> whaever number you like) are currently there.
> So, in my javascript loop before i try to load a slide image, i wanted
> to see if the pic was actualy there and if not I'd stop loading
> images, break out of the loop, and just proceed on with the reduced
> set Thanks

Ahh, you should have said so at first. This is actually easy; I have done
it before, myself.

Sometime before you show the images, check for size (height or width).
This is where the timing loop comes in; you need to be sure the image has
enough time to load before size-checking. If the size remains less than a
number somewhere around 40px, the default size of the missing-image
placement icon +1, the image is missing (or unloadable). I've forgotten if
you can check for size in a js image or not, ie:

var pic=new Image();
pic.src="leek.jpg";
var x=pic.width;

....but you can always use a hidden, absolutely-positioned placebo image on
the page if nothing else.

--
Neredbojias
Infinity has its limits.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация