Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org

Feedback: irt.org FAQ Knowledge Base Q52

Feedback on: irt.org FAQ Knowledge Base Q52

Sent by pablo on July 07, 2000 at 09:51:19: - feedback #1465

Worth:
Very worth reading

Comments:
Legal


Sent by Ryan Kelly on August 23, 2000 at 19:09:51: - feedback #1658

Worth:
Worth reading

Length:
Too short

Technical:
Just right

Comments:

You can also use the Image() object to test for the existence of a generic image (or any number of images) without ever displaying them on the page:

function testImage(URL)
{
var tester=new Image();
tester.onLoad=isGood;
tester.onError=isBad;
tester.src=URL;
}

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

function isBad()
{
alert('That image does no exist!');
}

This can be useful if, for example, the user must specify an image and you want to check whether it exists before submitting the form.


Sent by Bo on February 23, 2001 at 17:02:40: - feedback #2414

Worth:
Worth reading

Comments:
This solution dosn't seem to do it in MSIE, do you know a way to do it?


Sent by Ryan Kelly on June 12, 2001 at 18:41:58: - feedback #2832

Worth:
Very worth reading

Length:
Too long

Technical:
Too technical

Comments:

With regard to my previous comment, this code only seems to work in Netscape 4. It no longer runs in Netscape 6, or in IE.


Sent by Kim Moser on July 22, 2001 at 07:34:28: - feedback #2993

Worth:
Very worth reading

Length:
Just right

Technical:
Just right

Comments:
image.onLoad works for Netscape but for IE (at least for 5.5) you need to use image.onload (lowercase).


Sent by Ron Brown on April 13, 2002 at 05:16:42: - feedback #3781

Comments:
How could this be used to display an alternate graphic image if the specified image in a <img> tag doesn't exits? Assume that a standard image will be loaded for the alternate image.


Sent by ThomAce on Saturday June 30, 2007 at 10:11:52 - feedback #4755

Worth:

Length:

Technical:
Just right

Comments:
An another way to do this...

function ImageTest(URL) {
var
MyImage = new Image();
I = 0;

MyImage.onerror = DoesntExists;
MyImage.src = URL;

if(I > 0){
return('<your another picture link>');
}

function DoesntExists(){
I++;
}

return(URL);
}




Sent by funky on Saturday July 07, 2007 at 12:17:15 - feedback #4786

Worth:

Length:

Technical:

Comments:
onerror somehow doesn't work with some browsers. Wonder if there's a way to check if there was an error in onload instead...




©2018 Martin Webb