[Javascript] Image detection

Roland Neilands rneilands at pulsemining.com.au
Wed Apr 6 23:09:25 CDT 2005


Terry,

> I don't know if this helps or, not, but I think Walter Zorn is doing it
> somehow. Check out walterzorn.com
Thanks, that is useful and I may use part of that instead of resize buttons, but perhaps some code would be clearer. This is what
I've got so far:

       var objRegExp = new RegExp("jpg|gif|bmp|tif","i");

       if (objRegExp.test(filenames[imgno])) {
         SDViewer.TheImage.src = filenames[imgno];
       }
       else {
         SDViewer.location = filenames[imgno];
       }

It's for an intranet app to display basically any item the user sees fit to link. Trouble is scanned documents or photos could be
huge & they need to be able to shrink them to display or print the whole thing at once instead of a small corner. Preloading them
would also be useful, but again I need to know first if it is an image.

Cheers,
Roland

>
> > Does anyone know of a simple way of detecting in Javascript if a given
> > file is an image or not?
> >
> > I need to decide whether to load it into an <img> tag and provide
> > resize buttons or not.
> > Is checking a list of files extensions the only way?
> >
> > Regards,
> > Roland
> >
> >
> > _______________________________________________
> > Javascript mailing list
> > Javascript at LaTech.edu
> > https://lists.LaTech.edu/mailman/listinfo/javascript
> >
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>




More information about the Javascript mailing list