aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Dynamically know the image file not found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Dynamically know the image file not found" Watch "Dynamically know the image file not found" New topic
Author

Dynamically know the image file not found

kavin clain
Ranch Hand

Joined: Jan 19, 2010
Posts: 68
In javascript I am loading an image tag using ImageObj.src = 'loadimg.do';.

It works fine. But if the image file not found this way, then I want to set a default image.

My question is how to know the action 'loadimg.do' could not find the requested image.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

Best to handle that on the server.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
It would be better to do it on the server as mentioned.

There is a way to use



Eric
kavin clain
Ranch Hand

Joined: Jan 19, 2010
Posts: 68
I am using myeclipse. When I typed onerror... it was showing warning.
Then I checked http://www.w3schools.com/tags/tag_IMG.asp .

No such attribute defined for img tag. Even though,
I am going to try this code... but I think there should be one such attribute.
I tried the server side code & It is perfectly working.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
onerror is valid and it is not an attribute, it is a JavaScript event handler.

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

kavin clain wrote:I am using myeclipse.

What your IDE says is of no concern. IDEs are notoriously bad at client-side development.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dynamically know the image file not found