• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

how to check if image is loaded or not

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have to get book covers from amazon,librarything,openlibrary through webservice by giving isbn number...am getting book covers..but i have to check if amazon image is loaded or not..if amazon image is not available i have to go check librarything image..n i have to wait until image is loaded..only after loading image i have to check next image...
how do i do it using javascript...
can anyone give me solution...thanks in advance...
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Eric
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another way would be:



Within your js code, rather than referencing it on HTML element itself ... but the solution provided by other poster also works.

Trilochan
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Trilochan Bharadwaj wrote:


Except that addEventListener is not cross-browser.
 
Trilochan Bharadwaj
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
cross-browser event handling

I can't haggle on which approach is better because I am newbie myself, But If you have some time, you should do a look up on Event Model of W3C and google on "Non Obtrusive javascripting"
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Being a newbie, I'd highly recommend looking into a library such as jQuery that make cross-browser things like events and Ajax a breeze.

P.S. Please do not post in all uppercase. I have fixed it for you.
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Trilochan Bharadwaj wrote:But If you have some time, you should do a look up on Event Model of W3C and google on "Non Obtrusive javascripting"


To whom is this addressed?

You'll not find me arguing again Unobtrusive JavaScript; in fact, I wrote a book on it (with respect to jQuery).
 
Trilochan Bharadwaj
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I posted that tag to demonstrate how it cranks me up sometimes when we do things like <body onload="my entire script comes here, so have fun debugging this"></body> or something like that ... All I wanted to show this guy was, there are ways of doing this in a cross browser way and not stick onEvent stuff with js function calls ... I didn't intend to throw it out at you, I apologize if that caused you any concerns. No disrespect

I <3 JQuery! its such a sweet framework (I was a stickler for Dojo for a while, until I got hooked to JQuery, I am still learning it however ... ). What book are we talking about? I wanna get reference under my belt for JQuery, havent found anything handy except for documentation yet.


Trilochan.
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Trilochan Bharadwaj wrote:I posted that tag to demonstrate how it cranks me up ....


No one said you did anything wrong; I merely pointed out that the posted code was not cross-browser as that's important for any readers to know.

What book are we talking about? I wanna get reference under my belt for JQuery, havent found anything handy except for documentation yet.


jQuery in Action
 
Trilochan Bharadwaj
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah cool just what I was looking for, thanks!

trilochan.
 
Trilochan Bharadwaj
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Bear,

Thanks for the book link, I just got me a MEAP of second Ed. weee hee to JQuery!


Trilochan.
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great! Please be sure to leave any feedback for making the 2nd edition even better than the first on the books forum!
 
Without deviation from the norm, progress is not possible - Zappa. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic