/    Sign up×
Community /Pin to ProfileBookmark

how do you check if an image has loaded properly in javascript?

how do you check if an image has loaded properly in javascript?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@fredmvFeb 29.2004 — Please be more specific. Generally, you'd use [font=courier]onerror[/font] or [font=courier]onabort[/font], both of which may or may not be standardized.
Copy linkTweet thisAlerts:
@benjaminauthorFeb 29.2004 — i have a file browse thingy in a form and onchange makes that file appear on the page as a picture; if the picture has an error or it is an inavlid picture i want to call a function;

i do know i can use substring to find the extention but that does not stop files that have errors

any help much appreciated.
Copy linkTweet thisAlerts:
@fredmvFeb 29.2004 — Sure; that wouldn't be all that complex. Do you have any code you're currently working with or what? All you'd need to do is get the filename of the image, append it to the page and have the event handlers listening for an error.
×

Success!

Help @benjamin spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...